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

Update load_motion_info to load legacy motion folders #3772

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

alejoe91
Copy link
Member

When we added the Motion.load to the load_motion_info, we forgot to handle back-compatibility.

This PR just tries to load a legacy motion in case the Motion.load fails.

@alejoe91 alejoe91 added the preprocessing Related to preprocessing module label Mar 14, 2025
@alejoe91 alejoe91 requested review from samuelgarcia and zm711 March 14, 2025 14:01
Copy link
Collaborator

@zm711 zm711 left a comment

Choose a reason for hiding this comment

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

I know Sam prefers bool check over doing try/except (at least he seems to). What if we flipped the logic and checked for the legacy files and if all legacy files are present we load legacy. If not we load the current format and let the current format raise the IOError if its neither type. try/except are expensive if the except is used. This is probably the simplest version, but just wanted to raise the point.

Otherwise this looks fine to me.

EDIT: error appears to be related to building scipy. Not this PR.

@alejoe91
Copy link
Member Author

Good point @zm711

Got rid of try-except :)

@zm711
Copy link
Collaborator

zm711 commented Mar 14, 2025

Looks good to me. You want to do another PR to figure out the scipy build issue?

And do we have any way to test? Or do we not have a way to generate (simulated) legacy motion?

@alejoe91
Copy link
Member Author

Let's fix scipy in another PR. I don't think we need to test this since we would make up those three files...

Here it is in action:
image

temporal_bins_s = [np.load(folder / "temporal_bins.npy")]
displacement = [np.load(folder / "motion.npy")]

motion = Motion(displacement=displacement, temporal_bins_s=temporal_bins_s, spatial_bins_um=spatial_bins_um)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
motion = Motion(displacement=displacement, temporal_bins_s=temporal_bins_s, spatial_bins_um=spatial_bins_um)
motion = Motion(displacement=displacement, temporal_bins_s=[temporal_bins_s], spatial_bins_um=[spatial_bins_um])

Copy link
Collaborator

Choose a reason for hiding this comment

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

He already made them lists above. Do they have to be nested lists?

Copy link
Member Author

Choose a reason for hiding this comment

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

No :) I'm ok making the list later if it's better readable

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, let's leave it as is!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preprocessing Related to preprocessing module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants