UCL / PETPVC

Partial Volume Correction in PET
Apache License 2.0
51 stars 14 forks source link

Input masks #3

Closed pradeepthiyyagura closed 1 year ago

pradeepthiyyagura commented 8 years ago

Hi,

I am trying to test run the program with the RBV method as explained the methodology paper. Could you please give a few more details on how the mask file should be formatted to give as an input to petpvc program? I have the MRI data prepossessed using Freesurfer and the PET images co registered to the MRI.

Thanks, Pradeep

bathomas commented 8 years ago

Hi Pradeep,

Essentially you need to create a 4D volume where each 3D volume represents a brain region. There are two main steps: 1) Defining which brain regions you wish to correct. 2) Creating a 4D representation

1) The FreeSurfer (FS) parcellation is detailed and probably contains more regions than you would wish to PV-correct for. I would recommend merging the labels into a smaller set. If you take a look at https://surfer.nmr.mgh.harvard.edu/fswiki/CorticalParcellation, you could derive a lobe mapping similar to what is suggested. You can use the FS command mri_label2vol (http://surfer.nmr.mgh.harvard.edu/fswiki/mri_label2vol) to extract the regions. When you have all the 3D volumes (one per region), covering the whole brain and the background, biniarize these (fslmaths will do this).

2) A quick and easy way to create the 4D volume is to use fslmerge. This will concaternate all the 3D volumes into a 4D one.

The 4D mask can then be used in PETPVC. I hope this helps. We'll be adding some documentation on this in the near future.

Kind regards,

Ben

pradeepthiyyagura commented 8 years ago

Thank you for the reply.

I have used the wmparc.mgz file generated by freesurfer to generate 4Dmask file. This file is quite huge with 182 ROI mask files causing the program to crash as it ran out of memory trying to read it.

This problem did not occur when I merged a few ROI's so that there are 65 individual ROI's in the 4dmask file.

I was wondering if there is a more efficient way to read the input mask file so that the program wont run out of memory?

Thanks, Pradeep

bathomas commented 8 years ago

Hi,

Which version of ITK did you build PETPVC against? Also, doesn't wmparc.mgz only contain white matter regions?

Kind regards,

Ben

pradeepthiyyagura commented 8 years ago

Hello Thomas,

PETPVC is built against ITK4.9.0 and wmparc has white matter masks along with cortical and sub-cortical masks which sums up to 182 ROI's.

I got the following error when I tried PETPVC could you please take a look. I can send you my input file if that would help.

Thanks, Pradeep

P.S I have removed a few lines from the output so that I can past it in the comment box.

petpvc -i /rawdata/ADNI-PETC/quals/MC/03301410M4.nii -o GMT4.nii -m mask4d.nii -p GTM -x 4 -y 4 -z 4 Performing Geometric matrix method... /root/itk/InsightToolkit-4.9.0/Modules/ThirdParty/VNL/src/vxl/core/vnl/algo/vnl_svd.txx: suspicious return value (182) from SVDC /root/itk/InsightToolkit-4.9.0/Modules/ThirdParty/VNL/src/vxl/core/vnl/algo/vnl_svd.txx: M is 182x182 M = [ ... 0.99264 0.00000 0.00002 0.00003 0.00008 0.00004 0.00002 0.00011 0.00012 0.00008 0.00003 0.00014 0.00009 0.00005 0.00006 0.00011 0.00002 0.00005 0.00006 0.00003 0.00006 0.00002 0.00017 0.00004 0.00018 0.00011 0.00003 0.00022 0.00027 0.00018 0.00014 0.00011 0.00001 0.00003 0.00002 0.00006 0.00001 0.00000 0.00000 0.00000 0.00001 0.00000 0.00012 ... ... 0.00000 0 0.00018 0.00006 0 0 0 0.00002 0 0 0.00000 0.00000 0.00006 0.01362 0.00000 0.00247 0.00330 0.00451 0.00668 0 0 0.00003 0 0.00049 0 0 0 0.00026 0 0.00001 0.00000 0 0 0 0.00060 0 0.00000 0 0 0 0 0 0 0.00050 0 0 0.00011 0 0 0 0.00008 0 0 0 0 0.00024 0 0.03098 0.00011 0.00250 0 0 0.00005 0.00717 0.00005 0.00025 0.01091 0.00042 0.00013 0.01040 0.00035 0.00117 0.00033 0 0 0 0 0 0 0.00013 0 0.00099 0.00737 0 0.00002 0 0.00176 0.00006 0 0.00000 0.00003 0.01104 0.00055 0.29234 0.01806 0 0 0.06018 0.05509 0.01811 0.06738 0.00076 0.00059 0.00005 0.02170 0.00212 0.00000 0.00026 0.00212 0.00000 0.32235 0 0 0 0 0.01890 0 0 0 0 0 0 0.00003 0 0 0 0.00000 0 0.00009 0 0 0.00000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00180 0.01801 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00000 0 0 0 0 0 0 0.00000 0 0 0 0 0 0.00000 0 0 0.00000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00390 0.00519 0 0 0.00000 0 0 0 0 0 0 0 0 0 0 0 0.70722 0 0 0.24483 -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan 0.58346 0.00013 0 0 0 0 0 0 0 0 0 0 0 0 0.00860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00002 0.00000 0.06055 0 0 0 0 0.00007 0 0 0 0 0 0 0 0 0 0 0 0 0.00062 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00006 0 0 0 0 0 0 0.00055 0.03714 0 0 0 0 0 0 0 0 0 0 0 0 0 0.01461 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00013 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00058 0.00000 0 0 0 0 0 0 0.00007 0.00025 0.00000 0 0 0 0 0.00002 0 0.05283 0 0 0 0 0.24032 0 0.13635 0.00000 0 0 0 0 0 0.00715 0 0.00002 0.00000 0.00032 0 0.00224 0 0 0.00094 0 0 0 0 0 0 0 0 0.00000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00149 0.00286 0.00000 0 0 0 0 0 0 0 0 0 0 0.00000 0 0 0.00000 0 0 0 0 0 0 0 0 0 0 0 0.00000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00000 0 0 0 0 0 0.00063 0 0.00000 0.00000 0.00003 0 0.00037 0 0 0.00003 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00106 0.00917 0 0 0.00000 0 0 0 0 0 0 0 0 0 0 0 0.07616 0 0 0.76119 ] nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan

bathomas commented 8 years ago

Hi,

I suspect that you have some very small regions that may be causing problems. If you can send the mask I can take a look at it.

Kind regards,

Ben

pradeepthiyyagura commented 8 years ago

Thank you Ben. That hint helped identify the problem. Below are the masks I have in my 4D mask input file. Which are all the intensities present in wmparc.mgz and next to it are the number of voxels in each mask. It turns out that for some subjects the temp_80_non-WM-hypointensities.nii has no voxels in the ROI which caused the program to output nan's. I merged non-WM-hypointensities.nii with the background 0_Unknown.nii and the program ran with out any errors.

But, I did see some negative values in the program out put. Is that because some of the ROI are too small. Is there a threshold that I should set the for the size of masks below which they should be added to the background?

Mask_name n_voxels temp_0_Unknown.nii 15829795 temp_2_Left-Cerebral-White-Matter.nii 230 temp_4_Left-Lateral-Ventricle.nii 14835 temp_5_Left-Inf-Lat-Vent.nii 1139 temp_7_Left-Cerebellum-White-Matter.nii 12754 temp_8_Left-Cerebellum-Cortex.nii 41003 temp_10_Left-Thalamus-Proper.nii 6695 temp_11_Left-Caudate.nii 2950 temp_12_Left-Putamen.nii 4554 temp_13_Left-Pallidum.nii 1252 temp_14_3rd-Ventricle.nii 2075 temp_15_4th-Ventricle.nii 742 temp_16_Brain-Stem.nii 19488 temp_17_Left-Hippocampus.nii 2650 temp_18_Left-Amygdala.nii 754 temp_24_CSF.nii 1582 temp_26_Left-Accumbens-area.nii 341 temp_28_Left-VentralDC.nii 3143 temp_30_Left-vessel.nii 64 temp_31_Left-choroid-plexus.nii 1213 temp_41_Right-Cerebral-White-Matter.nii 339 temp_43_Right-Lateral-Ventricle.nii 17870 temp_44_Right-Inf-Lat-Vent.nii 1841 temp_46_Right-Cerebellum-White-Matter.nii 13380 temp_47_Right-Cerebellum-Cortex.nii 42132 temp_49_Right-Thalamus-Proper.nii 5782 temp_50_Right-Caudate.nii 2757 temp_51_Right-Putamen.nii 4039 temp_52_Right-Pallidum.nii 1368 temp_53_Right-Hippocampus.nii 2343 temp_54_Right-Amygdala.nii 745 temp_58_Right-Accumbens-area.nii 346 temp_60_Right-VentralDC.nii 3243 temp_62_Right-vessel.nii 89 temp_63_Right-choroid-plexus.nii 1957 temp_80_non-WM-hypointensities.nii 0 temp_85_Optic-Chiasm.nii 131 temp_251_CC_Posterior.nii 749 temp_252_CC_Mid_Posterior.nii 304 temp_253_CC_Central.nii 293 temp_254_CC_Mid_Anterior.nii 343 temp_255_CC_Anterior.nii 722 temp_1000_ctx-lh-unknown.nii 328 temp_1001_ctx-lh-bankssts.nii 1761 temp_1002_ctx-lh-caudalanteriorcingulate.nii 2020 temp_1003_ctx-lh-caudalmiddlefrontal.nii 5481 temp_1005_ctx-lh-cuneus.nii 2410 temp_1006_ctx-lh-entorhinal.nii 1233 temp_1007_ctx-lh-fusiform.nii 8552 temp_1008_ctx-lh-inferiorparietal.nii 7347 temp_1009_ctx-lh-inferiortemporal.nii 5283 temp_1010_ctx-lh-isthmuscingulate.nii 1546 temp_1011_ctx-lh-lateraloccipital.nii 8954 temp_1012_ctx-lh-lateralorbitofrontal.nii 5927 temp_1013_ctx-lh-lingual.nii 3574 temp_1014_ctx-lh-medialorbitofrontal.nii 3660 temp_1015_ctx-lh-middletemporal.nii 6680 temp_1016_ctx-lh-parahippocampal.nii 1346 temp_1017_ctx-lh-paracentral.nii 2920 temp_1018_ctx-lh-parsopercularis.nii 3646 temp_1019_ctx-lh-parsorbitalis.nii 1451 temp_1020_ctx-lh-parstriangularis.nii 3668 temp_1021_ctx-lh-pericalcarine.nii 1336 temp_1022_ctx-lh-postcentral.nii 8782 temp_1023_ctx-lh-posteriorcingulate.nii 2916 temp_1024_ctx-lh-precentral.nii 11756 temp_1025_ctx-lh-precuneus.nii 6572 temp_1026_ctx-lh-rostralanteriorcingulate.nii 2549 temp_1027_ctx-lh-rostralmiddlefrontal.nii 12763 temp_1028_ctx-lh-superiorfrontal.nii 17760 temp_1029_ctx-lh-superiorparietal.nii 10171 temp_1030_ctx-lh-superiortemporal.nii 8933 temp_1031_ctx-lh-supramarginal.nii 7224 temp_1032_ctx-lh-frontalpole.nii 728 temp_1033_ctx-lh-temporalpole.nii 2222 temp_1034_ctx-lh-transversetemporal.nii 1036 temp_1035_ctx-lh-insula.nii 5556 temp_2000_ctx-rh-unknown.nii 329 temp_2001_ctx-rh-bankssts.nii 1690 temp_2002_ctx-rh-caudalanteriorcingulate.nii 1506 temp_2003_ctx-rh-caudalmiddlefrontal.nii 4629 temp_2005_ctx-rh-cuneus.nii 2322 temp_2006_ctx-rh-entorhinal.nii 740 temp_2007_ctx-rh-fusiform.nii 5833 temp_2008_ctx-rh-inferiorparietal.nii 8286 temp_2009_ctx-rh-inferiortemporal.nii 5564 temp_2010_ctx-rh-isthmuscingulate.nii 1520 temp_2011_ctx-rh-lateraloccipital.nii 7427 temp_2012_ctx-rh-lateralorbitofrontal.nii 5583 temp_2013_ctx-rh-lingual.nii 4853 temp_2014_ctx-rh-medialorbitofrontal.nii 3427 temp_2015_ctx-rh-middletemporal.nii 6801 temp_2016_ctx-rh-parahippocampal.nii 1236 temp_2017_ctx-rh-paracentral.nii 3951 temp_2018_ctx-rh-parsopercularis.nii 2989 temp_2019_ctx-rh-parsorbitalis.nii 1770 temp_2020_ctx-rh-parstriangularis.nii 3501 temp_2021_ctx-rh-pericalcarine.nii 1698 temp_2022_ctx-rh-postcentral.nii 8237 temp_2023_ctx-rh-posteriorcingulate.nii 2490 temp_2024_ctx-rh-precentral.nii 12289 temp_2025_ctx-rh-precuneus.nii 5773 temp_2026_ctx-rh-rostralanteriorcingulate.nii 1690 temp_2027_ctx-rh-rostralmiddlefrontal.nii 12936 temp_2028_ctx-rh-superiorfrontal.nii 16827 temp_2029_ctx-rh-superiorparietal.nii 8769 temp_2030_ctx-rh-superiortemporal.nii 7541 temp_2031_ctx-rh-supramarginal.nii 6771 temp_2032_ctx-rh-frontalpole.nii 748 temp_2033_ctx-rh-temporalpole.nii 1615 temp_2034_ctx-rh-transversetemporal.nii 743 temp_2035_ctx-rh-insula.nii 5483 temp_3001_wm-lh-bankssts.nii 2270 temp_3002_wm-lh-caudalanteriorcingulate.nii 2541 temp_3003_wm-lh-caudalmiddlefrontal.nii 5823 temp_3005_wm-lh-cuneus.nii 2248 temp_3006_wm-lh-entorhinal.nii 505 temp_3007_wm-lh-fusiform.nii 6420 temp_3008_wm-lh-inferiorparietal.nii 6994 temp_3009_wm-lh-inferiortemporal.nii 3894 temp_3010_wm-lh-isthmuscingulate.nii 3306 temp_3011_wm-lh-lateraloccipital.nii 9891 temp_3012_wm-lh-lateralorbitofrontal.nii 5770 temp_3013_wm-lh-lingual.nii 4047 temp_3014_wm-lh-medialorbitofrontal.nii 2809 temp_3015_wm-lh-middletemporal.nii 3476 temp_3016_wm-lh-parahippocampal.nii 992 temp_3017_wm-lh-paracentral.nii 3436 temp_3018_wm-lh-parsopercularis.nii 3367 temp_3019_wm-lh-parsorbitalis.nii 705 temp_3020_wm-lh-parstriangularis.nii 3127 temp_3021_wm-lh-pericalcarine.nii 2957 temp_3022_wm-lh-postcentral.nii 7844 temp_3023_wm-lh-posteriorcingulate.nii 4288 temp_3024_wm-lh-precentral.nii 13716 temp_3025_wm-lh-precuneus.nii 8000 temp_3026_wm-lh-rostralanteriorcingulate.nii 2804 temp_3027_wm-lh-rostralmiddlefrontal.nii 12152 temp_3028_wm-lh-superiorfrontal.nii 14633 temp_3029_wm-lh-superiorparietal.nii 11277 temp_3030_wm-lh-superiortemporal.nii 7003 temp_3031_wm-lh-supramarginal.nii 6462 temp_3032_wm-lh-frontalpole.nii 236 temp_3033_wm-lh-temporalpole.nii 672 temp_3034_wm-lh-transversetemporal.nii 760 temp_3035_wm-lh-insula.nii 7388 temp_4001_wm-rh-bankssts.nii 1923 temp_4002_wm-rh-caudalanteriorcingulate.nii 2028 temp_4003_wm-rh-caudalmiddlefrontal.nii 4707 temp_4005_wm-rh-cuneus.nii 2262 temp_4006_wm-rh-entorhinal.nii 282 temp_4007_wm-rh-fusiform.nii 5152 temp_4008_wm-rh-inferiorparietal.nii 8454 temp_4009_wm-rh-inferiortemporal.nii 3558 temp_4010_wm-rh-isthmuscingulate.nii 2886 temp_4011_wm-rh-lateraloccipital.nii 7916 temp_4012_wm-rh-lateralorbitofrontal.nii 6051 temp_4013_wm-rh-lingual.nii 5550 temp_4014_wm-rh-medialorbitofrontal.nii 2820 temp_4015_wm-rh-middletemporal.nii 4019 temp_4016_wm-rh-parahippocampal.nii 830 temp_4017_wm-rh-paracentral.nii 4909 temp_4018_wm-rh-parsopercularis.nii 2531 temp_4019_wm-rh-parsorbitalis.nii 1022 temp_4020_wm-rh-parstriangularis.nii 2933 temp_4021_wm-rh-pericalcarine.nii 3476 temp_4022_wm-rh-postcentral.nii 6933 temp_4023_wm-rh-posteriorcingulate.nii 3385 temp_4024_wm-rh-precentral.nii 13165 temp_4025_wm-rh-precuneus.nii 7369 temp_4026_wm-rh-rostralanteriorcingulate.nii 1994 temp_4027_wm-rh-rostralmiddlefrontal.nii 11627 temp_4028_wm-rh-superiorfrontal.nii 14400 temp_4029_wm-rh-superiorparietal.nii 9316 temp_4030_wm-rh-superiortemporal.nii 5344 temp_4031_wm-rh-supramarginal.nii 6490 temp_4032_wm-rh-frontalpole.nii 284 temp_4033_wm-rh-temporalpole.nii 361 temp_4034_wm-rh-transversetemporal.nii 826 temp_4035_wm-rh-insula.nii 7952 temp_5001_Left-UnsegmentedWhiteMatter.nii 24567 temp_5002_Right-UnsegmentedWhiteMatter.nii 24373

bathomas commented 8 years ago

Dear Michael,

The MG requires a 4D mask that consists of two 3D volumes. The first volume must be GM and the second volume must be WM. You can add the CSF as a third volume if you wish, but the current implementation doesn't take that into account. Each 3D volume must have voxel values of between 0 and 1, stored as floating point numbers. You can use fslmerge to make merge the GM and WM into a 4D volume.

A blank output image usually means that there is something wrong with the mask. However, due the division in the MG technique, the output image can contain extremely large values. As many image viewing software scale to the maximum, the image can look blank. So just check that the problem isn't due to image scaling.

Kind regards,

Ben

On 2 September 2016 at 00:40, michaelbernier notifications@github.com wrote:

Hello,

I also have some troubles inputting the masks.. At first, I tried to use the MG pvc, which should require a probabilistic GM mask, WM mask and CSF (I think). It didn't work, so I tried GM and WM only (still didn't work). I then tried a background mask and GM mask, and again didn't work.. So at this point I am puzzled to guess what the toolbox needs to run. When I say it didn't work, it gives no errors, but output a blank image.

(BTW, amazing toolbox!) Michaël

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/UCL/PETPVC/issues/3#issuecomment-244138215, or mute the thread https://github.com/notifications/unsubscribe-auth/AGX4aRpvahTHdBA7LYleYHWRRbNyZ9Y4ks5qlwAIgaJpZM4HsB8S .

KrisThielemans commented 1 year ago

Closing as no further activity.