-
Notifications
You must be signed in to change notification settings - Fork 0
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
EDF time slicing #15
EDF time slicing #15
Conversation
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.
Bunch of comments and suggestions but feel free to ignore them. The only critical one to me is to clarify why the nwbfile.session_start_time is not used in the add_to_nwbfile
method of the EDFSignals interface.
@@ -17,6 +18,101 @@ | |||
from neuroconv.utils import DeepDict, dict_deep_update | |||
|
|||
|
|||
def get_session_start_time(folder_path: Union[str, Path]): |
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.
Shouldn't we just pass the file path of the json directly instead of passing the folder and then locating it within? What do you think?
I know you are moving these functions only but is something to consider if you think that a small breaking change is worth avoiding the problem of a different file structure in the future.
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.
My first design choice was to pass the file path actually. I don't remember why I changed my mind, probably to avoid to repeat pice of code. But if you also think passing the file_path is the correct way, I will change it back.
return session_start_time | ||
|
||
|
||
def get_miniscope_timestamps(miniscope_folder_path: Union[str, Path]): |
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.
Same comment here about the file_path vs folder_path?
@@ -205,36 +301,6 @@ def __init__(self, folder_path: DirectoryPath): | |||
|
|||
self.photon_series_type = "OnePhotonSeries" | |||
|
|||
def _get_session_start_time(self): |
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.
Another, equally valid option, is to make these functions static or class methods of the class. This is more of taste and preference and depends on how do you want to organize your code.
# Shift when the first timestamp is negative | ||
# TODO: Figure why, I copied from miniscope | ||
# TODO: Figure why, I copied from Miniscope. Need to shift also session_start_time |
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 this an answer to my why? or it was your why? The goal of this is to set the timestamps to start at 0, right?
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.
It was part od the TODO. If we saved the session start time from the metadata, and the timestamps refer to that date. When we shift the timestamps to zero we need to shift back the session start time as well. But I left it there as a comment because I am not sure how to handle this. I will open a follow up PR only on this
@@ -308,7 +366,7 @@ def add_to_nwbfile( | |||
imaging_extractor.set_times(times=miniscope_timestamps) | |||
|
|||
device_metadata = metadata["Ophys"]["Device"][0] | |||
# Cast to string because miniscope extension requires so | |||
# Cast to string because Miniscope extension requires so |
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.
Gratzie!
|
||
def __init__(self, file_path: FilePath, verbose: bool = False): | ||
|
||
def __init__( |
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 think these should be conversion options and not init arguments, as you might want to use run-time information (from other interfaces for example) to determine them.
|
||
|
||
def get_miniscope_folder_path(folder_path: Union[str, Path]): | ||
""" |
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.
Great
def get_session_start_time(folder_path: Union[str, Path]): | ||
""" | ||
Retrieve the session start time from metadata in the specified folder. | ||
|
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 also advice to name this get_{something}_start_time
now that is not a method of the class or modify the docstring to make this clear.
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.
changed_ in get_recording_start_time
src/cai_lab_to_nwb/zaki_2024/interfaces/zaki_2024_edf_interface.py
Outdated
Show resolved
Hide resolved
start_datetime_timestamp: datetime = None, | ||
stop_datetime_timestamp: datetime = None, | ||
verbose: bool = False, | ||
): |
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.
Also, if you add them here or in the conversion options (add_to_nwbfile) I think a docstring would be highly beneficial.
This is working good with your fix catalystneuro/neuroconv#1139 |
Add an option for slicing edf data based on the time range of miniscope recording.
datetime
format using the session start timedatetime
formatdatetime
format using EDF recording start timedatetime
format