Core Utilities¶
Core functions for project initialization, data loading, and configuration management.
Project Initialization¶
compass_labyrinth.init_project
¶
init_project(
project_name: str,
project_path: Path | str,
source_data_path: Path | str,
user_metadata_file_path: Path | str,
trial_type: str = "Labyrinth_DSI",
file_ext: str = ".csv",
video_type: str = ".mp4",
dlc_scorer: str = "DLC_resnet50_LabyrinthMar13shuffle1_1000000",
experimental_groups: list = ["A", "B", "C", "D"],
palette: str = "grey",
) -> tuple[dict, pd.DataFrame]
Initializes project for the CoMPASS-Labyrinth analysis, including: - Setting up directory structure - Copying user metadata file to project directory - Creating a config.yaml file with project parameters
Parameters:
-
project_name(str) –The name of the project.
-
project_path(Path | str) –The path to the project directory.
-
source_data_path(Path | str) –The path to the source data directory containing videos and DLC outputs.
-
user_metadata_file_path(Path | str) –The path to the user metadata Excel file.
-
trial_type(str, default:'Labyrinth_DSI') –Type of trial. Default is "Labyrinth_DSI".
-
file_ext(str, default:'.csv') –File extension for data files. Default is ".csv".
-
video_type(str, default:'.mp4') –Video file extension. Default is ".mp4".
-
dlc_scorer(str, default:'DLC_resnet50_LabyrinthMar13shuffle1_1000000') –DeepLabCut scorer identifier. Default is "DLC_resnet50_LabyrinthMar13shuffle1_1000000".
-
experimental_groups(list, default:['A', 'B', 'C', 'D']) –List of experimental groups. Default is ["A", "B", "C", "D"].
-
palette(str, default:'grey') –Color palette for visualizations. Default is "grey".
Returns:
-
config(dict) –A dictionary containing configuration parameters.
-
metadata_df(DataFrame) –A DataFrame containing cohort metadata.
Source code in src/compass_labyrinth/__init__.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
Data Loading Functions¶
load_project¶
compass_labyrinth.utils.load_project
¶
Loads configuration parameters and metadata from an existing project.
Parameters:
-
project_path(Path | str) –The path to the project directory containing the config.yaml and cohort_metadata.csv files.
Returns:
-
config(dict) –A dictionary containing configuration parameters.
-
metadata_df(DataFrame) –A DataFrame containing cohort metadata.
Source code in src/compass_labyrinth/utils.py
load_cohort_metadata¶
compass_labyrinth.utils.load_cohort_metadata
¶
Loads cohort metadata from the CSV file specified in the project configuration.
Parameters:
-
config(dict) –The project configuration dictionary containing the path to the cohort metadata CSV.
Returns:
-
metadata_df(DataFrame) –A DataFrame containing cohort metadata.
Source code in src/compass_labyrinth/utils.py
Figure Management¶
save_figure¶
compass_labyrinth.utils.save_figure
¶
save_figure(
config: dict,
fig_name: str,
subdir: str = "results/task_performance",
dpi: int = 300,
ext: str = "pdf",
)
Save the current matplotlib figure to a standardized results folder.
Parameters:
-
config(dict) –Project's configuration dictionary.
-
fig_name(str) –Name of the figure file, e.g., 'Shannons_entropy' or 'Bout_Success'. Extension is automatically appended as defined by
ext. -
subdir(str, default:'results/task_performance') –Subfolder path under BASE_PATH to save the figure.
-
dpi(int, default:300) –Resolution of saved figure.
-
ext(str, default:'pdf') –File extension, e.g., 'pdf', 'png', etc.