Skip to content

riekane/position_processing

Repository files navigation

Position processing

MATLAB pipeline that turns raw Vicon .c3d motion-capture files into the position data needed for beam-pattern analysis: microphone positions, maze geometry, and the bat flight trajectory, all in the Vicon global coordinate frame (mm).

This is the position half of the Vicon + Avisoft pipeline. Its two data outputs — the per-session mic position file and the per-trial bat_pos file — are later used in Beam pattern analysis.


Run it

Entry point: run_position_processing.m or master_position_processing.mlx (run either one). Set the config block at the top, then run:

date_data           = '20260623';      % capture date, yyyyMMdd
batID               = 'batA125';       % which bat
Mic_marker_distance = 35;              % mm from base marker to actual mic
floating_mic_ids    = [5 8 10 11 13 16];  % mic numbers that are movable, not wall-mounted

Path requirement: both this folder and position_processing\landmark must be on the MATLAB path (Home → Set Path → Add Folder).

The 5 steps:

  1. Mic positionsmic_landmarks() builds (or reuses) the per-session mic landmark file from raw .c3d captures, then extract_mic_location() extrapolates the actual mic position and pointing vector.
  2. Maze structureextract_maze_structure() reads y-maze_layout.json.
  3. Bat trajectoryextract_bat_pos() pulls the bat marker track from the selected trial .c3d.
  4. Save bat_possave_bat_pos() writes a Beampattern_analysis-ready .mat (see Outputs).
  5. Plotplot_bat_trajectory() draws 3D / top / side / time / speed figures. Plotting only; it writes no data.

Folders & outputs

Folder What's in it
Mic_positions\ Final computed mic files only: extract_mic_location.m writes mic_pos_<date>.csv/.mat (actual mic position + pointing vector, plus mic_loc/mic_vec aliases for Beampattern_analysis). The raw <date>_mic_loc landmark files live in landmark\mic_landmark_output\.
Bat_Position\ Per-trial bat_pos files: <batID>_<date>_<trial>_bat_pos.mat.
plot\ Saved figures / trajectory images only. No data files.
landmark\ Step-1 mic-landmark sub-pipeline (fixed + floating passes). Writes its raw <date>_mic_loc.csv/.mat into landmark\mic_landmark_output\. Has its own README.md.
y-maze_layout.json Maze landmark coordinates (walls, start line, take-off perch).
archive\, ezc3d_matlab\, legacy\ Superseded material and the ezc3d .c3d reader dependency.

bat_pos.mat contents (what Beampattern_analysis loads)

bat_pos (1×1 cell → [n_frames × 3], NaNs preserved), markers, frame_rate, maze, tp_position, lp_position, bat_marker_idx, selection_method, source_file.


Key functions

  • run_position_processing.m — top-level driver (steps 1–5 above).
  • extract_mic_location.m — mic landmark file → actual mic position + pointing vector; writes to Mic_positions\.
  • extract_maze_structure.m — parses y-maze_layout.json.
  • extract_bat_pos.m — bat marker trajectory from a trial .c3d.
  • save_bat_pos.m — writes the bat_pos .mat to Bat_Position\.
  • plot_bat_trajectory.m — all diagnostic figures.
  • landmark\ — the mic-landmark sub-pipeline (see its README).

Downstream

Beampattern_analysis's bp_proc.m loads the Bat_Position\*.mat track and the Mic_positions\ mic file (via the mic_loc / mic_vec aliases). Not produced here on purpose: mic_gain and mic_vh (recorder/calibration values) — merge those in on the audio side.

About

Processing Vicon data

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages