-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to save recordingless analyzer as #3443
Allow to save recordingless analyzer as #3443
Conversation
Hello, if I've already saved a import spikeinterface.full as si
sa = si.load_sorting_analyzer("my_sa")
sa._recording = None
sa_zarr = sa.save_as(format="zarr", folder="my_zarr_sa") Then the saved zarr folder has the correct folder structure but all the files are things like called things like |
Those are the name of zarr chunks :) The |
https://probeinterface.readthedocs.io/en/main/releases/0.2.18.html
If you're interested, you can check the hidden files. You should have a |
@@ -2015,7 +2023,10 @@ def copy(self, new_sorting_analyzer, unit_ids=None): | |||
new_extension.data = self.data | |||
else: | |||
new_extension.data = self._select_extension_data(unit_ids) | |||
new_extension.run_info = self.run_info.copy() | |||
if self.run_info is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you import copy from copy
you can use copy(self.run_info)
which returns None
if self.run_info
is None
, which would save some lines of code and indentations here and at line 2047.
I am not sure to like this. |
From the analyzer rec_attributes, which is always set! This is essential especially when loading an old waveform_extractor |
if self.format == "binary_folder": | ||
extension_folder = self._get_binary_extension_folder() | ||
run_info_file = extension_folder / "run_info.json" | ||
run_info_file.write_text(json.dumps(run_info, indent=4), encoding="utf8") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question I have here in general not related to this PR is if we encode with 'utf-8' will that then mess with other encoding systems? Or do we think that the encoding was really just limited to shell script issues? Is there any place where bouncing between encodings may bite us?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are building the dictionaries we are sure that they can be UTF-8 encoded and decoded, so I think it's safe!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about the case for paths where the paths include Chinese or Japanese characters, which can't be encoded with uft-8
? For run_info that doesn't matter, but I'm wondering about other json files we make. It might be that we just let people know that this works for utf-8 and may work for other encodings. But since most people on the team all use utf-8 I think it will be hard for us to know for sure for this. Doesn't really hold anything up I guess.
@@ -352,8 +353,6 @@ def create_memory(cls, sorting, recording, sparsity, return_scaled, rec_attribut | |||
def create_binary_folder(cls, folder, sorting, recording, sparsity, return_scaled, rec_attributes): | |||
# used by create and save_as | |||
|
|||
assert recording is not None, "To create a SortingAnalyzer you need to specify the recording" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we move this to the function def create_sorting_analyzer ?
with open(folder / "recording.json", mode="w") as f: | ||
json.dump({}, f, indent=4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would write nothing I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
recording.dump(folder / "recording.json", relative_to=folder) | ||
elif recording.check_serializability("pickle"): | ||
recording.dump(folder / "recording.pickle", relative_to=folder) | ||
if recording is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should have a mutualy exclusive between recording and rec_attributes in this function at some point
warnings.warn( | ||
"SortingAnalyzer with zarr : the Recording is not json serializable, the recording link will be lost for future load" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This warning should be also in the other format no ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it not there? I'll check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
This PR allows to save an analyzer as binary or zarr even if recordingless