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

Integration and validation tests with b=0 only #40

Closed
3 tasks done
oesteban opened this issue Apr 14, 2021 · 4 comments
Closed
3 tasks done

Integration and validation tests with b=0 only #40

oesteban opened this issue Apr 14, 2021 · 4 comments
Assignees
Labels
effort: medium Estimated medium-effort task good first issue Good for newcomers impact: high Estimated high-impact task validation
Milestone

Comments

@oesteban
Copy link
Member

oesteban commented Apr 14, 2021

Two low-hanging fruit tests using only a b=0:

  • Validation:
    • Unit tests of the TrivialB0Model implementation
    • Unit tests of ANTs' config for b=0.
  • Integration:
    • Introduce a series of transforms (e.g., copy them from another dataset) and resample the b=0 through that motion series. Then run the whole estimator and check the proximity of the estimated transforms.
@oesteban oesteban added effort: medium Estimated medium-effort task good first issue Good for newcomers impact: high Estimated high-impact task validation labels Apr 22, 2021
@oesteban oesteban added this to the 0.2.0 milestone Apr 22, 2021
oesteban added a commit that referenced this issue Nov 9, 2021
Sets up a barebones infrastructure for testing, hopefully to give a
kickstart to the work on #40.

cc/ @celprov, @sebastientourbier
@oesteban
Copy link
Member Author

oesteban commented Nov 9, 2021

Okay, I've tried to set up some basics, and implemented a unit-test for the TrivialB0Model sketching what we intend to do here:

def test_trivial_model():
"""Check the implementation of the trivial B0 model."""
# Should not allow initialization without a B0
with pytest.raises(ValueError):
model.TrivialB0Model(gtab=np.eye(4))
_S0 = np.random.normal(size=(10, 10, 10))
tmodel = model.TrivialB0Model(gtab=np.eye(4), S0=_S0)
assert tmodel.fit() is None
assert np.all(_S0 == tmodel.predict((1, 0, 0)))

Unit tests of ANTs' config for b=0.

I see this implemented in test_estimator.py. To do so:

  • Upload an example B0 map (3D)
  • Apply random (and small) rotations and translations on the image. These can be generated with nibabel.eulerangles.euler2mat (e.g., https://github.com/poldracklab/nitransforms/blob/master/nitransforms/tests/test_linear.py#L107). For the resampling, I would use nitransforms.linear.Affine.resample().
  • Run the registration interface loading the parameters from config
  • Check that the error of the affine is below some threshold when transforming points scattered across the volume.

Introduce a series of transforms (e.g., copy them from another dataset) and resample the b=0 through that motion series. Then run the whole estimator and check the proximity of the estimated transforms.

I see this implemented in test_integration.py. To do so:

  • Upload an example B0 map (3D) - or reuse from the previous test
  • Generate a series of moved B0's with the realignment matrices from another, real dataset.
  • Initiate the TrivialB0Model with this B0 map and feed the dwi object with the moved data (simulate perhaps several transforms).

@oesteban
Copy link
Member Author

oesteban commented Nov 9, 2021

Hi there! I've uploaded some data under https://github.com/nipreps/eddymotion/tree/main/eddymotion/tests/data, generated by @dPys with FiberFox.

@celprov celprov mentioned this issue Nov 9, 2021
@sebastientourbier
Copy link
Contributor

sebastientourbier commented Nov 10, 2021

@oesteban I am progressing! For now, I managed to:

  • extract the b0 volume from the sub-01_dwi.nii.gz provided by Céline.
  • run AFNI 3dvolreg on the fmri of the first run, first subject of ds000005 (240 time frames) on openneuro with the middle frame as reference. This gives me a text file where one line corresponds to the motion parameters for one time frame.
  • make 20 copies of the b0 where I applied the motion parameters from the last 20 frames (with nitransforms), saved in temporary niftis.
  • save a unique 4D nifti image that concatenates the original and the moving b0s

I haven't opened a PR yet but here is a quick preview of the motion introduced

b0 moving

What do think?

@dPys
Copy link
Contributor

dPys commented Nov 10, 2021

This looks so awesome.

arokem pushed a commit that referenced this issue Jun 24, 2022
Sets up a barebones infrastructure for testing, hopefully to give a
kickstart to the work on #40.

cc/ @celprov, @sebastientourbier


Former-commit-id: 152e0d4
Former-commit-id: 723b8b0
arokem pushed a commit that referenced this issue Jun 24, 2022
Sets up a barebones infrastructure for testing, hopefully to give a
kickstart to the work on #40.

cc/ @celprov, @sebastientourbier


Former-commit-id: 805760b [formerly 152e0d4]
Former-commit-id: 723b8b0
Former-commit-id: 2be92b3
mathdugre pushed a commit to mathdugre/eddymotion that referenced this issue Jun 24, 2022
Sets up a barebones infrastructure for testing, hopefully to give a
kickstart to the work on nipreps#40.

cc/ @celprov, @sebastientourbier
mathdugre pushed a commit to mathdugre/eddymotion that referenced this issue Jun 24, 2022
Sets up a barebones infrastructure for testing, hopefully to give a
kickstart to the work on nipreps#40.

cc/ @celprov, @sebastientourbier
oesteban added a commit that referenced this issue Jun 30, 2022
Sets up a barebones infrastructure for testing, hopefully to give a
kickstart to the work on #40.

cc/ @celprov, @sebastientourbier


Former-commit-id: 152e0d4
oesteban added a commit that referenced this issue Aug 25, 2022
Drops the use of a real AFNI series of transforms. Instead, generate a
number of large-yet-plausible transformations for head motion.

Follow-up: #84.
Part-of: #40.
oesteban added a commit that referenced this issue Aug 25, 2022
Drops the use of a real AFNI series of transforms. Instead, generate a
number of large-yet-plausible transformations for head motion.

Follow-up: #84.
Part-of: #40.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort: medium Estimated medium-effort task good first issue Good for newcomers impact: high Estimated high-impact task validation
Projects
None yet
Development

No branches or pull requests

4 participants