|
22 | 22 | import glob |
23 | 23 | import hashlib |
24 | 24 | import os |
| 25 | +import pathlib |
25 | 26 |
|
26 | 27 | import h5py |
27 | 28 | import joblib |
|
41 | 42 | from cebra.datasets.allen import SEEDS |
42 | 43 | from cebra.datasets.allen import SEEDS_DISJOINT |
43 | 44 |
|
| 45 | +_DEFAULT_DATADIR = get_datapath() |
| 46 | + |
44 | 47 |
|
45 | 48 | @parametrize( |
46 | 49 | "allen-movie-{num_movie}-ca-{cortex}-{num_neurons}-{split_flag}-{test_repeat}-{seed}", |
@@ -107,9 +110,9 @@ def _get_video_features(self, num_movie="one"): |
107 | 110 |
|
108 | 111 | """ |
109 | 112 |
|
110 | | - frame_feature_path = get_datapath( |
111 | | - f"allen/features/allen_movies/vit_base/8/movie_{num_movie}_image_stack.npz/testfeat.pth" |
112 | | - ) |
| 113 | + frame_feature_path = pathlib.Path( |
| 114 | + _DEFAULT_DATADIR |
| 115 | + ) / "allen" / "features" / "allen_movies" / "vit_base" / "8" / f"movie_{num_movie}_image_stack.npz" / "testfeat.pth" |
113 | 116 | frame_feature = torch.load(frame_feature_path) |
114 | 117 | return frame_feature |
115 | 118 |
|
@@ -171,15 +174,14 @@ def _get_pseudo_mice(self, area, num_movie): |
171 | 174 |
|
172 | 175 | """ |
173 | 176 |
|
174 | | - list_mice = glob.glob( |
175 | | - get_datapath( |
176 | | - f"allen/visual_drift/data/calcium_excitatory/{area}/*")) |
177 | | - exp_containers = [ |
178 | | - int(mice.split(f"{area}/")[1].replace(".mat", "")) |
179 | | - for mice in list_mice |
180 | | - ] |
| 177 | + path = pathlib.Path( |
| 178 | + _DEFAULT_DATADIR |
| 179 | + ) / "allen" / "visual_drift" / "data" / "calcium_excitatory" / str(area) |
| 180 | + list_mice = path.glob("*.mat") |
| 181 | + exp_containers = [int(file.stem) for file in list_mice] |
181 | 182 | ## Load summary file |
182 | | - summary = pd.read_csv(get_datapath("allen/data_summary.csv")) |
| 183 | + summary = pd.read_csv( |
| 184 | + pathlib.Path(_DEFAULT_DATADIR) / "allen" / "data_summary.csv") |
183 | 185 | ## Filter excitatory neurons in V1 |
184 | 186 | area_filtered = summary[(summary["exp"].isin(exp_containers)) & |
185 | 187 | (summary["target"] == area) & |
@@ -223,9 +225,10 @@ def _convert_to_nums(string): |
223 | 225 | indices2.sort() |
224 | 226 | indices3.sort() |
225 | 227 | indices = [indices1, indices2, indices3] |
226 | | - matfile = get_datapath( |
227 | | - f"allen/visual_drift/data/calcium_excitatory/{area}/{exp_container}.mat" |
228 | | - ) |
| 228 | + matfile = pathlib.Path( |
| 229 | + _DEFAULT_DATADIR |
| 230 | + ) / "allen" / "visual_drift" / "data" / "calcium_excitatory" / str( |
| 231 | + area) / f"{exp_container}.mat" |
229 | 232 | traces = scipy.io.loadmat(matfile) |
230 | 233 | for n, i in enumerate(seq_sessions): |
231 | 234 | session = traces["filtered_traces_days_events"][n, 0][ |
@@ -325,10 +328,10 @@ def _get_pseudo_mice(self, area, num_movie): |
325 | 328 | area: The visual cortical area to sample the neurons. Possible options: VISp, VISpm, VISam, VISal, VISl, VISrl. |
326 | 329 |
|
327 | 330 | """ |
328 | | - |
329 | | - list_mice = glob.glob( |
330 | | - get_datapath( |
331 | | - f"allen/visual_drift/data/calcium_excitatory/{area}/*")) |
| 331 | + path = pathlib.Path( |
| 332 | + _DEFAULT_DATADIR |
| 333 | + ) / "allen" / "visual_drift" / "data" / "calcium_excitatory" / str(area) |
| 334 | + list_mice = path.glob("*") |
332 | 335 |
|
333 | 336 | def _get_neural_data(num_movie, mat_file): |
334 | 337 | mat = scipy.io.loadmat(mat_file) |
|
0 commit comments