cibrrig.preprocess.extract_physiology
Command line script to extract and downsample physiological data from NIDAQ recording. The recorded auxiliary data (e.g. diaphragm and pleth) is sampled at 10K. While the high sampling rate is critical to acquire good EMG, it is excessive for both the integrated and the pleth.
This script does the following: 1) Downsamples the Flow/Pdiff traces by 10x to be input into breathmetrics (BM does filtering and processing) 2) Filters the EMG (300-5K) 3) Integrates the EMG with a triangular window 4) Downsamples the integrated EMG by 10x to match the pleth 5) Extracts features from the integrated EMG. 6) Extracts heart rate from EKG channel if recorded 6) Saves to alf standardized files in the session path
Attributes
Functions
|
Utility to crop both the time trace and an arbitrary vector to the same length (shortest length). |
Get the trigger number from the filename |
|
|
Categorize breaths as sighs or eupnea based on the diaphragm data. |
|
Process physiological data from a single recording. |
|
Run the physiology extraction process on a session. |
|
Main entry point for the physiology extraction script. |
Module Contents
- cibrrig.preprocess.extract_physiology.BM_PATH = '/active/ramirez_j/ramirezlab/nbush/projects/cibrrig/cibrrig/preprocess'[source]
- cibrrig.preprocess.extract_physiology._crop_traces(t, x)[source]
Utility to crop both the time trace and an arbitrary vector to the same length (shortest length). Useful to prevent off-by-one errors.
- Parameters:
t (np.ndarray) – Time stamps for each element in x.
x (np.ndarray) – Signal vector.
- Returns:
- A tuple containing:
np.ndarray: Cropped timestamp array.
np.ndarray: Cropped Signal vector.
- Return type:
tuple
- cibrrig.preprocess.extract_physiology._get_trigger_from_SR(SR)[source]
Get the trigger number from the filename
- Parameters:
SR (spikeglx.Reader) – Spikeglx reader object
- Returns:
Trigger label extracted from the filename (e.g., ‘t0’, ‘t1’, etc.)
- Return type:
str
- cibrrig.preprocess.extract_physiology.label_sighs(dia_df)[source]
Categorize breaths as sighs or eupnea based on the diaphragm data.
- Parameters:
dia_df (pd.DataFrame) – DataFrame containing diaphragm data with columns ‘on_sec’ and ‘auc’.
- Returns:
DataFrame with additional columns ‘breath_type’, ‘is_sigh’, and ‘is_eupnea’.
- Return type:
pd.DataFrame
- cibrrig.preprocess.extract_physiology.run_one(SR, wiring, v_in, inhale_pos, save_path)[source]
Process physiological data from a single recording. Passes data to functions in the physiology module to process and save the data.
- Parameters:
SR (spikeglx.Reader) – SpikeGLX reader object for the recording.
wiring (dict) – Wiring configuration.
v_in (float) – Voltage input.
inhale_pos (int) – Inhale position.
save_path (Path) – Path to save the processed data.
- Returns:
None
- cibrrig.preprocess.extract_physiology.run(session_path, v_in=9, inhale_pos=False, save_path=None, debug=False)[source]
Run the physiology extraction process on a session.
- Parameters:
session_path (Path) – Path to the session data.
v_in (float, optional) – Voltage supply for the flowmeter sensor. Defaults to 9.
inhale_pos (bool, optional) – Set true if inhale was acquired as a positive signal. Defaults to False.
save_path (Path, optional) – Path to save data to. If None, save to parent directory of binary file. Defaults to None.
debug (bool, optional) – If True, enable debug loggin. Defaults to False.
- cibrrig.preprocess.extract_physiology.main(session_path, v_in, inhale_pos, save_path, debug)[source]
Main entry point for the physiology extraction script.
- Parameters:
session_path (str) – Path to the session data.
v_in (float, optional) – Voltage supply for the flowmeter sensor. Defaults to 9.
inhale_pos (bool, optional) – Set true if inhale was acquired as a positive signal. Defaults to False.
save_path (str, optional) – Path to save data to. If None, save to parent directory of binary file. Defaults to None.
debug (bool) – If True, enable debug mode.