Giter VIP home page Giter VIP logo

Comments (10)

schuhschuh avatar schuhschuh commented on July 24, 2024 1

Very sorry for the late reply, this error usually suggests that there is no overlap between the images to be registered (or maybe that one image is completely empty). It may be worthwhile to check any previous registration output that was computed, e.g., an affine transformation supposed to align the images before deformable registration.

from dhcp-structural-pipeline.

schuhschuh avatar schuhschuh commented on July 24, 2024

Thanks, could you also attach the *.additional.err file?

from dhcp-structural-pipeline.

anisha1807 avatar anisha1807 commented on July 24, 2024

subject1-session1.additional.err.txt

I created a text file since it doesn't allow me to directly attach the .err file. But the content is the same.

from dhcp-structural-pipeline.

anisha1807 avatar anisha1807 commented on July 24, 2024

TC_0432_T2_reg.nii.gz
Here is the file I am trying to process.

from dhcp-structural-pipeline.

schuhschuh avatar schuhschuh commented on July 24, 2024

Thanks, @anisha1807. I was able to reproduce the issue.

In short, see at the end regarding a bug in scripts/misc/pipeline.sh which causes this issue, where target and source input images to the mirtk register command are in the wrong order. Below a more detailed tracing of the issue.

Looking at the input to the registration command, it appears that one of the transformations which should be the inverse of another is indeed actually almost identical to this other transformation. More concretely, I looked at the following:

docker cp dhcp-container:/usr/src/structural-pipeline/parameters/../atlases/non-rigid-v2/T2/template-40.nii.gz .
docker cp dhcp-container:/usr/src/structural-pipeline/parameters/../atlases/non-rigid-v2/T2/template-44.nii.gz .

mirtk view \
    -target template-{40,44}.nii.gz \
    -source workdir/subject1-session1/restore/T2/subject1-session1_restore_bet.nii.gz \
    -dofin workdir/subject1-session1/dofs/template-44-subject1-session1-n.dof.gz \
           workdir/subject1-session1/dofs/subject1-session1-template-44-n.dof.gz

When looking at these images, I have to check the box "Invert transformation" in both cases to achieve the expected alignment in the Viewer. This suggests that subject1-session1-template-44-n.dof.gz is correct, but template-44-subject1-session1-n.dof.gz is not as it should be the inverse of it.

At least one of these transformation files is computed by the segmentation/pipeline.sh script, which in turn simply executes the Draw-EM command

mirtk neonatal-segmentation /data/workdir/subject1-session1/T2/subject1-session1.nii.gz 44 -t 4 -c 1 -p 1 -v 1 -atlas non-rigid-v2

I thus first suspected the issue is with Draw-EM. Above neontal-segmentation command registers the 44 week template to the bias corrected input image at this line. This computes the transformation dofs/subject1-session1-template-44-n.dof.gz, i.e., the one we identified above as correct (which explains why the Draw-EM segmentations in workdir/subject1-session1/segmentations/ look fine). Looking through all the steps of mirtk neonatal-segmentation script, it does indeed not produce nor use the incorrect inverse transformation. So the issue is more likely in the dHCP pipeline then.

Indeed it seems another registration is executed in the additional pipeline:

if [ ! -f dofs/template-$age-$subj-n.dof.gz ];then
run mirtk register $T2masked $template_T2/template-$age.nii.gz -dofout dofs/template-$age-$subj-n.dof.gz -parin $registration_config_template -threads $threads -v 0
fi

^^^ This command is the culprit.

The order of target and source suggest that the output transformation maps points from input image to template space, but the naming of the output transformation suggests it should be the mapping from template to input space rather.

@jcupitt Can you have a look at this? This bug seems to be present since @amakropoulos initial commit in 2017. Odd though that it wouldn't have caused issue before?!? Has maybe something else changed more recently?

Also, instead of this extra registration step, it would make sense to just use

mirtk invert-dof dofs/subject1-session1-template-44-n.dof.gz dofs/template-44-subject1-session1-n.dof.gz

when the image to template mapping is available from the Draw-EM output.

from dhcp-structural-pipeline.

schuhschuh avatar schuhschuh commented on July 24, 2024

@jcupitt found the solution! [EDIT: :-) seems John was faster actually fixing it than me posting this update...]

The incorrect code block referenced above seems obsolete, and was supposed to be replaced by the lines below it:

if [ ! -f dofs/template-$age-$subj-n.dof.gz ];then
run mirtk invert-dof dofs/$subj-template-$age-n.dof.gz dofs/template-$age-$subj-i.dof.gz
run mirtk register $template_T2/template-$age.nii.gz $T2masked -dofin dofs/template-$age-$subj-i.dof.gz -dofout dofs/template-$age-$subj-n.dof.gz -parin $registration_config_template -threads $threads -v 0
run rm dofs/template-$age-$subj-i.dof.gz
fi

Removing below lines from scripts/misc/pipeline.sh resolves the issue.

if [ ! -f dofs/template-$age-$subj-n.dof.gz ];then
run mirtk register $T2masked $template_T2/template-$age.nii.gz -dofout dofs/template-$age-$subj-n.dof.gz -parin $registration_config_template -threads $threads -v 0
fi

Thanks, @anisha1807, for bringing this to our attention and sorry for the long wait. @jcupitt will submit a fix soon, which should then also update the Docker image.

from dhcp-structural-pipeline.

schuhschuh avatar schuhschuh commented on July 24, 2024

For reference, @amakropoulos also fixed this issue less than 1 month ago in the original repo DevelopingHCP@5f7942d

from dhcp-structural-pipeline.

jcupitt avatar jcupitt commented on July 24, 2024

And Andreas found the issue heh.

from dhcp-structural-pipeline.

jcupitt avatar jcupitt commented on July 24, 2024

Oh goodness, I didn't realize the original repo was still being updated. Are there any other fixes we should pick up?

from dhcp-structural-pipeline.

schuhschuh avatar schuhschuh commented on July 24, 2024

Not for now [I think]. I'll be talking to Antonis next week. There are some other MIRTK issues still outstanding. He had planned to then contribute those upstream once ready and working, I belief.

from dhcp-structural-pipeline.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.