Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ When altering tables, import all foreign key references.
- Thing
-->

### Decoding

- Ensure results directory is created if it doesn't exist #1362

## [0.5.5] (Aug 6, 2025)

### Infrastructure
Expand Down
10 changes: 7 additions & 3 deletions src/spyglass/decoding/v1/clusterless.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 7 additions & 3 deletions src/spyglass/decoding/v1/sorted_spikes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading