Skip to content
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

Align the starting_time of the processed fiber photometry data #29

Merged
merged 7 commits into from
May 27, 2024

Conversation

weiglszonja
Copy link
Collaborator

After looking at the converted files I noticed that some recordings might be cropped (the picoscope data was longer than the processed data). After digging into their processing code I found out that in some cases they were cropping the beginning of the recording and saving the crop point named "cropStart".

I'm using this variable to align the starting time of the processed interface, so we are saving the processed behavior data and fiber photometry data with the correct starting time.

@weiglszonja
Copy link
Collaborator Author

Example 20200205-0001.nwb:
Screenshot 2024-05-23 at 15 37 04 (2)

@weiglszonja weiglszonja marked this pull request as draft May 23, 2024 13:58
@weiglszonja
Copy link
Collaborator Author

I'll first test this for all sessions and then reopen, sorry for pinging too early @alessandratrapani

@weiglszonja
Copy link
Collaborator Author

weiglszonja commented May 24, 2024

@alessandratrapani I think this is ready for review (we can discuss in our next meeting if something is unclear), also will add this as a note for the mid-way meeting to double check with them.

@weiglszonja weiglszonja marked this pull request as ready for review May 24, 2024 13:21
Copy link
Contributor

@alessandratrapani alessandratrapani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is clear to me. Looks good!

Comment on lines +54 to +71
def get_original_timestamps(self) -> np.ndarray:
binned_photometry_data = read_mat(filename=str(self.file_path))["#subsystem#"]["MCOS"][2]
channel_index = self.column_names.index("chMov")
data = binned_photometry_data[channel_index]
if len(self.depth_ids) > 1:
data = data[self.depth_index]
num_frames = len(data)
return np.arange(num_frames) / self._sampling_frequency

def get_timestamps(self, stub_test: bool = False) -> np.ndarray:
timestamps = self._timestamps if self._timestamps is not None else self.get_original_timestamps()
if stub_test:
return timestamps[:6000]
return timestamps

def set_aligned_timestamps(self, aligned_timestamps: np.ndarray) -> None:
self._timestamps = np.array(aligned_timestamps)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weiglszonja weiglszonja merged commit e46ff8e into main May 27, 2024
@weiglszonja weiglszonja deleted the temporal_alignment branch May 27, 2024 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants