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

Reproducibility in PFT tracking #1596

Closed
GuillaumeTh opened this Issue Jul 25, 2018 · 8 comments

Comments

Projects
None yet
3 participants
@GuillaumeTh
Copy link
Contributor

GuillaumeTh commented Jul 25, 2018

After some tests with @jchoude on the PFT tracking, we saw a issue. If we run twice the algorithm with maps slightly differents (1 voxel), the tracking is not reproducible.

I think it could be cool to have a reproducibility of 99% on the tracking if the maps are reproducible at 99%.

We need to set the random seed follow the voxel and the global random seed( random.seed(voxel_id * random_seed) ).

I checked the files where we need this and they are:

tracking/utils.py -> random_seeds_from_mask
tracking/local/localtrack.pyx -> _pft line 482 and line 502
direction -> probabilitic_direction_getter.pyx line 120

What do you think about this feature @gabknight

@gabknight

This comment has been minimized.

Copy link
Contributor

gabknight commented Jul 25, 2018

@GuillaumeTh This will be nice to have, but this isn't limited to PFT. This should be implemented for all tracking algorithms. I think this should go in tracking/local/direction_getter as a function setting the random state, which should be called in LocalTracking and ParticleFilteringTracking before starting the tracking from an initial seed position. The random seed should not only be based on the voxel_id, otherwise all streamline started at the same voxel will be identical or biased in one direction. Maybe voxel id and seed_count? This could also be floating point 3D position of the seed, thus an identical seed will then always give an identical streamline, but then this removes the option to generate e.g. 1k streamlines from the very same seeding position.

I'm not sure here how this should be done...

@GuillaumeTh

This comment has been minimized.

Copy link
Contributor

GuillaumeTh commented Jul 25, 2018

I think the random seed for each seed tracking could be what you said. I will try to have a draft and check if it's easy to do or not.

@gabknight

This comment has been minimized.

Copy link
Contributor

gabknight commented Jul 25, 2018

Ok thx let me know if I can help with this.

I wouldn't "reset" the random seed in the middle of streamline being traced (localtracking.pyx:502), as this would biais the overall reconstruction.

@GuillaumeTh

This comment has been minimized.

Copy link
Contributor

GuillaumeTh commented Jul 25, 2018

So I tested something and It seems to work.

Finally I changed the function random_seed_from_mask to add a random_seed argument. Moreover I compute the same seeds in a same voxels follow the random_seed argument.

Before the initial_direction, I setted the numpy.random and random seed. With these modifications, I am reproducible at 99% if the masks are reproducible at 99%.

@GuillaumeTh

This comment has been minimized.

Copy link
Contributor

GuillaumeTh commented Jul 27, 2018

So @gabknight, I can create a PR if you want to see.

@skoudoro Are you ok to review this functionality ?

@skoudoro

This comment has been minimized.

Copy link
Member

skoudoro commented Jul 27, 2018

No problem @GuillaumeTh, but first, I just need to fix our problem with Travis.

@GuillaumeTh

This comment has been minimized.

Copy link
Contributor

GuillaumeTh commented Jul 27, 2018

@skoudoro Can I create the PR with the Travis problem ?

@skoudoro

This comment has been minimized.

Copy link
Member

skoudoro commented Jul 27, 2018

yes, #1601 fix it.

When this PR is merged, you can rebase yours

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment