muschellij2 / extrantsr

R Package to build on ANTsR
GNU General Public License v3.0
6 stars 3 forks source link

Apply multiple binary ROI to a single registration / transformation process and get them back as outfiles? #5

Closed Filojoe closed 7 years ago

Filojoe commented 7 years ago

Dear Prof. Muschelli, Firs of all, thank you for your kind support all the way!!!!!

My issue: I am currently registering a T1 Template to 3 different quantitative MRI sequences using the following code as you suggested in the "issue section" before.

reg = registration(filename = t1_template,
                   outfile = "some output file/path",
                   #other.files = other_metrical_file_paths,
                   other.outfiles = "some output file",
                   template.file = any quantitative sequence i want to register on,
                     interpolator = "linear")
res = ants_apply_transforms(fixed = any quantitative sequence,
                            moving = ROI, transformlist = reg$fwdtransforms,
                            interpolator = "nearestNeighbor")
mapply(function(img, fname) {
  writeNIfTI(res, "output name of the ROI file")
  }, res, "data/output/inverse/" )

The Problem: I have defined 10 regions of interest in the cerebral white matter on the T1 template of each subject (right frontal, left frontal, right parietal and so on...) and saved each of the ROI masks as a single binary file (nii.gz) resulting in 10 ROI files/masks which i want to transform to the space of the fixed file (in my case 3 registration attempts in order to register the T1 template to each one of the quantitative sequences).

My idea was to include the 10 different ROI files in the code line:

res = ants_apply_transforms(fixed = any quantitative sequence,
                            moving = ROI files...., transformlist = reg$fwdtransforms,
                            interpolator = "nearestNeighbor")

as the moving files. However this woks fine with a single File (readnii before and insert the ROI file as moving file) but in my case i need 10 ROI wrapped within 1 transformation / registration process. After that i want each of the 10 then transformed ROI to be put out as a new nii.gz file in my outfolder for further processing with in house scripts.

To sum it up: I have this registration function which works really fine, the registered image looks very good! I have 10 ROI (each saved as a binary nii.gz file) which i want to apply during the registration process so that they will match on the registered image space after registration for ROI analysis. Futhermore, i want the transformed 10 ROI files from the new space to be put out in my folder so i can process them further and read them out / get the quantitative values for each ROI. It works pretty fine with 1 ROI at a time though, which indicates that i am going in the right direction. Is there something like an array so i can put in multiple ROI files within the antsapplytransforms code? And how do i get each of the 10 ROI back as an outfile after transformation / registration has been performed? Where do i need insert the which code line?

I am kind of new in AntsR and R programming so i am sorry if the problem might be "easy to fix" but this really gives me a headache.

Thank you so much for helping!!! Kind regards!