diff --git a/CHANGELOG.md b/CHANGELOG.md index 256d0bfcf..ef0fd002a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,14 @@ When altering tables, import all foreign key references. - Delete extra pyscripts that were renamed # 1363 +### Decoding + +- Ensure results directory is created if it doesn't exist #1362 + +### Spikesorting + +- Implement short-transaction `SpikeSortingRecording.make` for v0 #1338 + ## [0.5.5] (Aug 6, 2025) ### Infrastructure @@ -90,7 +98,6 @@ When altering tables, import all foreign key references. present in nwb file electrodes table #1310, #1334 - Ensure matching order of returned merge_ids and nwb files in `SortedSpikesGroup.fetch_spike_data` #1320 - - Implement short-transaction `SpikeSortingRecording.make` #1338 - Behavior - Implement pipeline for keypoint-moseq extraction of behavior syllables #1056 - LFP diff --git a/src/spyglass/decoding/v1/clusterless.py b/src/spyglass/decoding/v1/clusterless.py index baa281152..6b0449591 100644 --- a/src/spyglass/decoding/v1/clusterless.py +++ b/src/spyglass/decoding/v1/clusterless.py @@ -279,15 +279,19 @@ def make(self, key): nwb_file_name = key["nwb_file_name"].replace("_.nwb", "") + # Make sure the results directory exists + results_dir = Path(config["SPYGLASS_ANALYSIS_DIR"]) / nwb_file_name + results_dir.mkdir(parents=True, exist_ok=True) + # Generate a unique path for the results file path_exists = True while path_exists: results_path = ( - Path(config["SPYGLASS_ANALYSIS_DIR"]) - / nwb_file_name - / f"{nwb_file_name}_{str(uuid.uuid4())}.nc" + results_dir / f"{nwb_file_name}_{str(uuid.uuid4())}.nc" ) + # if the results_path already exists, try a different uuid path_exists = results_path.exists() + classifier.save_results( results, results_path, diff --git a/src/spyglass/decoding/v1/sorted_spikes.py b/src/spyglass/decoding/v1/sorted_spikes.py index 7b4ede194..9be6bdced 100644 --- a/src/spyglass/decoding/v1/sorted_spikes.py +++ b/src/spyglass/decoding/v1/sorted_spikes.py @@ -236,15 +236,19 @@ def make(self, key): nwb_file_name = key["nwb_file_name"].replace("_.nwb", "") + # Make sure the results directory exists + results_dir = Path(config["SPYGLASS_ANALYSIS_DIR"]) / nwb_file_name + results_dir.mkdir(parents=True, exist_ok=True) + # Generate a unique path for the results file path_exists = True while path_exists: results_path = ( - Path(config["SPYGLASS_ANALYSIS_DIR"]) - / nwb_file_name - / f"{nwb_file_name}_{str(uuid.uuid4())}.nc" + results_dir / f"{nwb_file_name}_{str(uuid.uuid4())}.nc" ) + # if the results_path already exists, try a different uuid path_exists = results_path.exists() + classifier.save_results( results, results_path,