From vladimir.fonov at gmail.com Thu Mar 3 18:10:33 2016 From: vladimir.fonov at gmail.com (Vladimir S. FONOV) Date: Thu, 3 Mar 2016 18:10:33 -0500 Subject: [MINC-development] -labels support in minccalc, mincmath and mincresample Message-ID: <56D8C469.2090109@gmail.com> Hello MINC developers, I made changes to libminc ( https://github.com/BIC-MNI/libminc/tree/develop-labels ) And minc-tools ( https://github.com/BIC-MNI/minc-tools/tree/develop-labels ) to add support for -labels option in minccalc,mincmath and mincresample, to try to address the common problem that many people seem to have over and over again and again - inter-slice normalization of volumes with integer labels. Description of the problem: When you have a minc file that contains discrete levels (i.e anatomical labels) produced, for example, by manual labeling in Display or ITK-SNAP. You apply some simple operation using minccalc (for example intersecting your labels with a mask, or doing some logical operations) you inadvertently produce a volume where the actual discrete values for voxles are replaced by floating-point ones. What's worse is the rule of this replacement depends on the data type used for the minc file, dimension order of the file and particular location of the voxel within the file. Example: minccalc -express 'A[0]*2' /opt/minc/share/icbm152_model_09c/mni_icbm152_t1_tal_nlin_sym_09c_deep2.mnc test.mnc Here I take a file that contains 15 labels describing deep gray matter structures and multiply each label by 2. The contents of the input file (using print_all_labels): Label: 1 6931 Label: 2 16801 Label: 3 1499 Label: 4 175210 Label: 5 5789 Label: 6 1404 Label: 7 909 Label: 8 4992 Label: 9 8512 Label: 101 6931 Label: 103 1499 Label: 106 1404 Label: 107 909 Label: 108 4992 Label: 109 8512 The contents of the output file : Label: 2 6649 *Label: 3 282* Label: 4 16801 Label: 6 1499 Label: 8 175210 Label: 10 5789 Label: 12 1404 Label: 14 857 *Label: 15 52* Label: 16 4992 Label: 18 8512 Label: 202 6931 Label: 206 1499 Label: 212 1404 Label: 214 857 *Label: 215 52* Label: 216 4992 Label: 218 8512 Note the highlighted Labels: 3,15,215 which are clearly not possible when one multiplies integer labels by 2. Solution (using the -labels option): minccalc -labels -express 'A[0]*2' /opt/minc/share/icbm152_model_09c/mni_icbm152_t1_tal_nlin_sym_09c_deep2.mnc test_labels.mnc The output is now correct: Label: 2 6931 Label: 4 16801 Label: 6 1499 Label: 8 175210 Label: 10 5789 Label: 12 1404 Label: 14 909 Label: 16 4992 Label: 18 8512 Label: 202 6931 Label: 206 1499 Label: 212 1404 Label: 214 909 Label: 216 4992 Label: 218 8512 -- Best regards, Vladimir S. FONOV ~ vladimir.fonov gmail.com From a.janke at gmail.com Thu Mar 3 19:45:14 2016 From: a.janke at gmail.com (Andrew Janke) Date: Fri, 4 Mar 2016 10:45:14 +1000 Subject: [MINC-development] -labels support in minccalc, mincmath and mincresample In-Reply-To: <56D8C469.2090109@gmail.com> References: <56D8C469.2090109@gmail.com> Message-ID: ace stuff. I like it a lot. any chance we can introduce a label header tag somewhere so that this happens by default for label files? I can think of a few edge cases but this should usually be right? thanks a On 04/03/2016 9:10 AM, "Vladimir S. FONOV" wrote: > Hello MINC developers, > > > I made changes to libminc ( > https://github.com/BIC-MNI/libminc/tree/develop-labels ) > > And minc-tools ( https://github.com/BIC-MNI/minc-tools/tree/develop-labels > ) to add support for -labels option in minccalc,mincmath and mincresample, > to try to address the common problem that many people seem to have over and > over again and again - inter-slice normalization of volumes with integer > labels. > > Description of the problem: > > When you have a minc file that contains discrete levels (i.e anatomical > labels) produced, for example, by manual labeling in Display or ITK-SNAP. > You apply some simple operation using minccalc (for example intersecting > your labels with a mask, or doing some logical operations) you > inadvertently produce a volume where the actual discrete values for voxles > are replaced by floating-point ones. What's worse is the rule of this > replacement depends on the data type used for the minc file, dimension > order of the file and particular location of the voxel within the file. > > Example: > > minccalc -express 'A[0]*2' > /opt/minc/share/icbm152_model_09c/mni_icbm152_t1_tal_nlin_sym_09c_deep2.mnc > test.mnc > > Here I take a file that contains 15 labels describing deep gray matter > structures and multiply each label by 2. > The contents of the input file (using print_all_labels): > Label: 1 6931 > Label: 2 16801 > Label: 3 1499 > Label: 4 175210 > Label: 5 5789 > Label: 6 1404 > Label: 7 909 > Label: 8 4992 > Label: 9 8512 > Label: 101 6931 > Label: 103 1499 > Label: 106 1404 > Label: 107 909 > Label: 108 4992 > Label: 109 8512 > > The contents of the output file : > Label: 2 6649 > *Label: 3 282* > Label: 4 16801 > Label: 6 1499 > Label: 8 175210 > Label: 10 5789 > Label: 12 1404 > Label: 14 857 > *Label: 15 52* > Label: 16 4992 > Label: 18 8512 > Label: 202 6931 > Label: 206 1499 > Label: 212 1404 > Label: 214 857 > *Label: 215 52* > Label: 216 4992 > Label: 218 8512 > > > Note the highlighted Labels: 3,15,215 which are clearly not possible when > one multiplies integer labels by 2. > > Solution (using the -labels option): > minccalc -labels -express 'A[0]*2' > /opt/minc/share/icbm152_model_09c/mni_icbm152_t1_tal_nlin_sym_09c_deep2.mnc > test_labels.mnc > > The output is now correct: > Label: 2 6931 > Label: 4 16801 > Label: 6 1499 > Label: 8 175210 > Label: 10 5789 > Label: 12 1404 > Label: 14 909 > Label: 16 4992 > Label: 18 8512 > Label: 202 6931 > Label: 206 1499 > Label: 212 1404 > Label: 214 909 > Label: 216 4992 > Label: 218 8512 > > > -- > Best regards, > > Vladimir S. FONOV ~ vladimir.fonov gmail.com > _______________________________________________ > MINC-development mailing list > MINC-development at bic.mni.mcgill.ca > http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-development > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mishkind at gmail.com Thu Mar 3 21:40:40 2016 From: mishkind at gmail.com (Mishkin Derakhshan) Date: Thu, 3 Mar 2016 16:40:40 -1000 Subject: [MINC-development] -labels support in minccalc, mincmath and mincresample In-Reply-To: References: <56D8C469.2090109@gmail.com> Message-ID: really a great idea and very much needed for minccalc and mincmath. for mincreseample, would this be any different than using -nearest_neighbour? On Thu, Mar 3, 2016 at 2:45 PM, Andrew Janke wrote: > ace stuff. > > I like it a lot. any chance we can introduce a label header tag somewhere > so that this happens by default for label files? > > I can think of a few edge cases but this should usually be right? > > thanks > > a > > On 04/03/2016 9:10 AM, "Vladimir S. FONOV" wrote: >> >> Hello MINC developers, >> >> >> I made changes to libminc ( >> https://github.com/BIC-MNI/libminc/tree/develop-labels ) >> >> And minc-tools ( https://github.com/BIC-MNI/minc-tools/tree/develop-labels >> ) to add support for -labels option in minccalc,mincmath and mincresample, >> to try to address the common problem that many people seem to have over and >> over again and again - inter-slice normalization of volumes with integer >> labels. >> >> Description of the problem: >> >> When you have a minc file that contains discrete levels (i.e anatomical >> labels) produced, for example, by manual labeling in Display or ITK-SNAP. >> You apply some simple operation using minccalc (for example intersecting >> your labels with a mask, or doing some logical operations) you inadvertently >> produce a volume where the actual discrete values for voxles are replaced by >> floating-point ones. What's worse is the rule of this replacement depends on >> the data type used for the minc file, dimension order of the file and >> particular location of the voxel within the file. >> >> Example: >> >> minccalc -express 'A[0]*2' >> /opt/minc/share/icbm152_model_09c/mni_icbm152_t1_tal_nlin_sym_09c_deep2.mnc >> test.mnc >> >> Here I take a file that contains 15 labels describing deep gray matter >> structures and multiply each label by 2. >> The contents of the input file (using print_all_labels): >> Label: 1 6931 >> Label: 2 16801 >> Label: 3 1499 >> Label: 4 175210 >> Label: 5 5789 >> Label: 6 1404 >> Label: 7 909 >> Label: 8 4992 >> Label: 9 8512 >> Label: 101 6931 >> Label: 103 1499 >> Label: 106 1404 >> Label: 107 909 >> Label: 108 4992 >> Label: 109 8512 >> >> The contents of the output file : >> Label: 2 6649 >> *Label: 3 282* >> Label: 4 16801 >> Label: 6 1499 >> Label: 8 175210 >> Label: 10 5789 >> Label: 12 1404 >> Label: 14 857 >> *Label: 15 52* >> Label: 16 4992 >> Label: 18 8512 >> Label: 202 6931 >> Label: 206 1499 >> Label: 212 1404 >> Label: 214 857 >> *Label: 215 52* >> Label: 216 4992 >> Label: 218 8512 >> >> >> Note the highlighted Labels: 3,15,215 which are clearly not possible when >> one multiplies integer labels by 2. >> >> Solution (using the -labels option): >> minccalc -labels -express 'A[0]*2' >> /opt/minc/share/icbm152_model_09c/mni_icbm152_t1_tal_nlin_sym_09c_deep2.mnc >> test_labels.mnc >> >> The output is now correct: >> Label: 2 6931 >> Label: 4 16801 >> Label: 6 1499 >> Label: 8 175210 >> Label: 10 5789 >> Label: 12 1404 >> Label: 14 909 >> Label: 16 4992 >> Label: 18 8512 >> Label: 202 6931 >> Label: 206 1499 >> Label: 212 1404 >> Label: 214 909 >> Label: 216 4992 >> Label: 218 8512 >> >> >> -- >> Best regards, >> >> Vladimir S. FONOV ~ vladimir.fonov gmail.com >> _______________________________________________ >> MINC-development mailing list >> MINC-development at bic.mni.mcgill.ca >> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-development > > > _______________________________________________ > MINC-development mailing list > MINC-development at bic.mni.mcgill.ca > http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-development > From robert.d.vincent at mcgill.ca Fri Mar 4 07:03:13 2016 From: robert.d.vincent at mcgill.ca (Robert D. Vincent) Date: Fri, 4 Mar 2016 07:03:13 -0500 Subject: [MINC-development] -labels support in minccalc, mincmath and mincresample In-Reply-To: References: <56D8C469.2090109@gmail.com> Message-ID: Hi Vlad, Thanks for tackling this - it's long overdue. Regarding Andrew's comments, I'll look into adding support for the long-neglected "class" field we defined for MINC 2 files - it was supposed to help solve this problem, by marking label files as one of "real", "integer", "label", etc. -bert On Thu, Mar 3, 2016 at 7:45 PM, Andrew Janke wrote: > ace stuff. > > I like it a lot. any chance we can introduce a label header tag somewhere > so that this happens by default for label files? > > I can think of a few edge cases but this should usually be right? > > thanks > > a > On 04/03/2016 9:10 AM, "Vladimir S. FONOV" > wrote: > >> Hello MINC developers, >> >> >> I made changes to libminc ( >> https://github.com/BIC-MNI/libminc/tree/develop-labels ) >> >> And minc-tools ( >> https://github.com/BIC-MNI/minc-tools/tree/develop-labels ) to add >> support for -labels option in minccalc,mincmath and mincresample, to try to >> address the common problem that many people seem to have over and over >> again and again - inter-slice normalization of volumes with integer labels. >> >> Description of the problem: >> >> When you have a minc file that contains discrete levels (i.e anatomical >> labels) produced, for example, by manual labeling in Display or ITK-SNAP. >> You apply some simple operation using minccalc (for example intersecting >> your labels with a mask, or doing some logical operations) you >> inadvertently produce a volume where the actual discrete values for voxles >> are replaced by floating-point ones. What's worse is the rule of this >> replacement depends on the data type used for the minc file, dimension >> order of the file and particular location of the voxel within the file. >> >> Example: >> >> minccalc -express 'A[0]*2' >> /opt/minc/share/icbm152_model_09c/mni_icbm152_t1_tal_nlin_sym_09c_deep2.mnc >> test.mnc >> >> Here I take a file that contains 15 labels describing deep gray matter >> structures and multiply each label by 2. >> The contents of the input file (using print_all_labels): >> Label: 1 6931 >> Label: 2 16801 >> Label: 3 1499 >> Label: 4 175210 >> Label: 5 5789 >> Label: 6 1404 >> Label: 7 909 >> Label: 8 4992 >> Label: 9 8512 >> Label: 101 6931 >> Label: 103 1499 >> Label: 106 1404 >> Label: 107 909 >> Label: 108 4992 >> Label: 109 8512 >> >> The contents of the output file : >> Label: 2 6649 >> *Label: 3 282* >> Label: 4 16801 >> Label: 6 1499 >> Label: 8 175210 >> Label: 10 5789 >> Label: 12 1404 >> Label: 14 857 >> *Label: 15 52* >> Label: 16 4992 >> Label: 18 8512 >> Label: 202 6931 >> Label: 206 1499 >> Label: 212 1404 >> Label: 214 857 >> *Label: 215 52* >> Label: 216 4992 >> Label: 218 8512 >> >> >> Note the highlighted Labels: 3,15,215 which are clearly not possible when >> one multiplies integer labels by 2. >> >> Solution (using the -labels option): >> minccalc -labels -express 'A[0]*2' >> /opt/minc/share/icbm152_model_09c/mni_icbm152_t1_tal_nlin_sym_09c_deep2.mnc >> test_labels.mnc >> >> The output is now correct: >> Label: 2 6931 >> Label: 4 16801 >> Label: 6 1499 >> Label: 8 175210 >> Label: 10 5789 >> Label: 12 1404 >> Label: 14 909 >> Label: 16 4992 >> Label: 18 8512 >> Label: 202 6931 >> Label: 206 1499 >> Label: 212 1404 >> Label: 214 909 >> Label: 216 4992 >> Label: 218 8512 >> >> >> -- >> Best regards, >> >> Vladimir S. FONOV ~ vladimir.fonov gmail.com >> _______________________________________________ >> MINC-development mailing list >> MINC-development at bic.mni.mcgill.ca >> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-development >> > > _______________________________________________ > MINC-development mailing list > MINC-development at bic.mni.mcgill.ca > http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-development > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zijdenbos at gmail.com Fri Mar 4 08:19:38 2016 From: zijdenbos at gmail.com (Alex Zijdenbos) Date: Fri, 4 Mar 2016 08:19:38 -0500 Subject: [MINC-development] -labels support in minccalc, mincmath and mincresample In-Reply-To: References: <56D8C469.2090109@gmail.com> Message-ID: <1DA5B6C0-DE04-48AB-AA85-6078DA5ED2A3@gmail.com> Very cool - I didn't think this was ever going to be tackled :)) Great work! -- A Sent from mobile > On Mar 4, 2016, at 07:03, Robert D. Vincent wrote: > > Hi Vlad, > > Thanks for tackling this - it's long overdue. Regarding Andrew's comments, I'll look into adding support for the long-neglected "class" field we defined for MINC 2 files - it was supposed to help solve this problem, by marking label files as one of "real", "integer", "label", etc. > > -bert > >> On Thu, Mar 3, 2016 at 7:45 PM, Andrew Janke wrote: >> ace stuff. >> >> I like it a lot. any chance we can introduce a label header tag somewhere so that this happens by default for label files? >> >> I can think of a few edge cases but this should usually be right? >> >> thanks >> >> a >> >>> On 04/03/2016 9:10 AM, "Vladimir S. FONOV" wrote: >>> Hello MINC developers, >>> >>> >>> I made changes to libminc ( https://github.com/BIC-MNI/libminc/tree/develop-labels ) >>> >>> And minc-tools ( https://github.com/BIC-MNI/minc-tools/tree/develop-labels ) to add support for -labels option in minccalc,mincmath and mincresample, to try to address the common problem that many people seem to have over and over again and again - inter-slice normalization of volumes with integer labels. >>> >>> Description of the problem: >>> >>> When you have a minc file that contains discrete levels (i.e anatomical labels) produced, for example, by manual labeling in Display or ITK-SNAP. You apply some simple operation using minccalc (for example intersecting your labels with a mask, or doing some logical operations) you inadvertently produce a volume where the actual discrete values for voxles are replaced by floating-point ones. What's worse is the rule of this replacement depends on the data type used for the minc file, dimension order of the file and particular location of the voxel within the file. >>> >>> Example: >>> >>> minccalc -express 'A[0]*2' /opt/minc/share/icbm152_model_09c/mni_icbm152_t1_tal_nlin_sym_09c_deep2.mnc test.mnc >>> >>> Here I take a file that contains 15 labels describing deep gray matter structures and multiply each label by 2. >>> The contents of the input file (using print_all_labels): >>> Label: 1 6931 >>> Label: 2 16801 >>> Label: 3 1499 >>> Label: 4 175210 >>> Label: 5 5789 >>> Label: 6 1404 >>> Label: 7 909 >>> Label: 8 4992 >>> Label: 9 8512 >>> Label: 101 6931 >>> Label: 103 1499 >>> Label: 106 1404 >>> Label: 107 909 >>> Label: 108 4992 >>> Label: 109 8512 >>> >>> The contents of the output file : >>> Label: 2 6649 >>> *Label: 3 282* >>> Label: 4 16801 >>> Label: 6 1499 >>> Label: 8 175210 >>> Label: 10 5789 >>> Label: 12 1404 >>> Label: 14 857 >>> *Label: 15 52* >>> Label: 16 4992 >>> Label: 18 8512 >>> Label: 202 6931 >>> Label: 206 1499 >>> Label: 212 1404 >>> Label: 214 857 >>> *Label: 215 52* >>> Label: 216 4992 >>> Label: 218 8512 >>> >>> >>> Note the highlighted Labels: 3,15,215 which are clearly not possible when one multiplies integer labels by 2. >>> >>> Solution (using the -labels option): >>> minccalc -labels -express 'A[0]*2' /opt/minc/share/icbm152_model_09c/mni_icbm152_t1_tal_nlin_sym_09c_deep2.mnc test_labels.mnc >>> >>> The output is now correct: >>> Label: 2 6931 >>> Label: 4 16801 >>> Label: 6 1499 >>> Label: 8 175210 >>> Label: 10 5789 >>> Label: 12 1404 >>> Label: 14 909 >>> Label: 16 4992 >>> Label: 18 8512 >>> Label: 202 6931 >>> Label: 206 1499 >>> Label: 212 1404 >>> Label: 214 909 >>> Label: 216 4992 >>> Label: 218 8512 >>> >>> >>> -- >>> Best regards, >>> >>> Vladimir S. FONOV ~ vladimir.fonov gmail.com >>> _______________________________________________ >>> MINC-development mailing list >>> MINC-development at bic.mni.mcgill.ca >>> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-development >> >> _______________________________________________ >> MINC-development mailing list >> MINC-development at bic.mni.mcgill.ca >> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-development > > _______________________________________________ > MINC-development mailing list > MINC-development at bic.mni.mcgill.ca > http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-development -------------- next part -------------- An HTML attachment was scrubbed... URL: From vladimir.fonov at gmail.com Fri Mar 4 10:14:06 2016 From: vladimir.fonov at gmail.com (Vladimir S. FONOV) Date: Fri, 4 Mar 2016 10:14:06 -0500 Subject: [MINC-development] -labels support in minccalc, mincmath and mincresample In-Reply-To: References: <56D8C469.2090109@gmail.com> Message-ID: There is a special datatype "label" in MINC2 file format, unfortunately it is not supported by any standard minc tools. Maybe somebody could modify MINC1 API to properly translate this data type to an integer class for legacy apps ? I.e see https://github.com/BIC-MNI/libminc/blob/master/testdir/minc2-label-test.c On Fri, Mar 4, 2016 at 7:03 AM, Robert D. Vincent < robert.d.vincent at mcgill.ca> wrote: > Hi Vlad, > > Thanks for tackling this - it's long overdue. Regarding Andrew's comments, > I'll look into adding support for the long-neglected "class" field we > defined for MINC 2 files - it was supposed to help solve this problem, by > marking label files as one of "real", "integer", "label", etc. > > -bert > > On Thu, Mar 3, 2016 at 7:45 PM, Andrew Janke wrote: > >> ace stuff. >> >> I like it a lot. any chance we can introduce a label header tag >> somewhere so that this happens by default for label files? >> >> I can think of a few edge cases but this should usually be right? >> >> thanks >> >> a >> On 04/03/2016 9:10 AM, "Vladimir S. FONOV" >> wrote: >> >>> Hello MINC developers, >>> >>> >>> I made changes to libminc ( >>> https://github.com/BIC-MNI/libminc/tree/develop-labels ) >>> >>> And minc-tools ( >>> https://github.com/BIC-MNI/minc-tools/tree/develop-labels ) to add >>> support for -labels option in minccalc,mincmath and mincresample, to try to >>> address the common problem that many people seem to have over and over >>> again and again - inter-slice normalization of volumes with integer labels. >>> >>> Description of the problem: >>> >>> When you have a minc file that contains discrete levels (i.e anatomical >>> labels) produced, for example, by manual labeling in Display or ITK-SNAP. >>> You apply some simple operation using minccalc (for example intersecting >>> your labels with a mask, or doing some logical operations) you >>> inadvertently produce a volume where the actual discrete values for voxles >>> are replaced by floating-point ones. What's worse is the rule of this >>> replacement depends on the data type used for the minc file, dimension >>> order of the file and particular location of the voxel within the file. >>> >>> Example: >>> >>> minccalc -express 'A[0]*2' >>> /opt/minc/share/icbm152_model_09c/mni_icbm152_t1_tal_nlin_sym_09c_deep2.mnc >>> test.mnc >>> >>> Here I take a file that contains 15 labels describing deep gray matter >>> structures and multiply each label by 2. >>> The contents of the input file (using print_all_labels): >>> Label: 1 6931 >>> Label: 2 16801 >>> Label: 3 1499 >>> Label: 4 175210 >>> Label: 5 5789 >>> Label: 6 1404 >>> Label: 7 909 >>> Label: 8 4992 >>> Label: 9 8512 >>> Label: 101 6931 >>> Label: 103 1499 >>> Label: 106 1404 >>> Label: 107 909 >>> Label: 108 4992 >>> Label: 109 8512 >>> >>> The contents of the output file : >>> Label: 2 6649 >>> *Label: 3 282* >>> Label: 4 16801 >>> Label: 6 1499 >>> Label: 8 175210 >>> Label: 10 5789 >>> Label: 12 1404 >>> Label: 14 857 >>> *Label: 15 52* >>> Label: 16 4992 >>> Label: 18 8512 >>> Label: 202 6931 >>> Label: 206 1499 >>> Label: 212 1404 >>> Label: 214 857 >>> *Label: 215 52* >>> Label: 216 4992 >>> Label: 218 8512 >>> >>> >>> Note the highlighted Labels: 3,15,215 which are clearly not possible >>> when one multiplies integer labels by 2. >>> >>> Solution (using the -labels option): >>> minccalc -labels -express 'A[0]*2' >>> /opt/minc/share/icbm152_model_09c/mni_icbm152_t1_tal_nlin_sym_09c_deep2.mnc >>> test_labels.mnc >>> >>> The output is now correct: >>> Label: 2 6931 >>> Label: 4 16801 >>> Label: 6 1499 >>> Label: 8 175210 >>> Label: 10 5789 >>> Label: 12 1404 >>> Label: 14 909 >>> Label: 16 4992 >>> Label: 18 8512 >>> Label: 202 6931 >>> Label: 206 1499 >>> Label: 212 1404 >>> Label: 214 909 >>> Label: 216 4992 >>> Label: 218 8512 >>> >>> >>> -- >>> Best regards, >>> >>> Vladimir S. FONOV ~ vladimir.fonov gmail.com >>> _______________________________________________ >>> MINC-development mailing list >>> MINC-development at bic.mni.mcgill.ca >>> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-development >>> >> >> _______________________________________________ >> MINC-development mailing list >> MINC-development at bic.mni.mcgill.ca >> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-development >> >> > > _______________________________________________ > MINC-development mailing list > MINC-development at bic.mni.mcgill.ca > http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-development > > -- Best regards, Vladimir S. Fonov ~ vladimir fonov gmail com -------------- next part -------------- An HTML attachment was scrubbed... URL: From v.s.fonov at ilmarin.info Fri Mar 4 09:57:44 2016 From: v.s.fonov at ilmarin.info (Vladimir S. FONOV) Date: Fri, 4 Mar 2016 09:57:44 -0500 Subject: [MINC-development] -labels support in minccalc, mincmath and mincresample In-Reply-To: References: <56D8C469.2090109@gmail.com> Message-ID: <35D4784A-3EDB-4E2E-8926-F1A751860B93@ilmarin.info> Hello, unfortunately, using -nearest_neighbour does not guarantee absence of the slice-normalization rounding error. So, one will have to use -labels -nearest to achieve the desired effect. > On Mar 3, 2016, at 21:40, Mishkin Derakhshan wrote: > > really a great idea and very much needed for minccalc and mincmath. > for mincreseample, would this be any different than using -nearest_neighbour? > > On Thu, Mar 3, 2016 at 2:45 PM, Andrew Janke wrote: >> ace stuff. >> >> I like it a lot. any chance we can introduce a label header tag somewhere >> so that this happens by default for label files? >> >> I can think of a few edge cases but this should usually be right? >> >> thanks >> >> a >> >> On 04/03/2016 9:10 AM, "Vladimir S. FONOV" wrote: >>> >>> Hello MINC developers, >>> >>> >>> I made changes to libminc ( >>> https://github.com/BIC-MNI/libminc/tree/develop-labels ) >>> >>> And minc-tools ( https://github.com/BIC-MNI/minc-tools/tree/develop-labels >>> ) to add support for -labels option in minccalc,mincmath and mincresample, >>> to try to address the common problem that many people seem to have over and >>> over again and again - inter-slice normalization of volumes with integer >>> labels. >>> >>> Description of the problem: >>> >>> When you have a minc file that contains discrete levels (i.e anatomical >>> labels) produced, for example, by manual labeling in Display or ITK-SNAP. >>> You apply some simple operation using minccalc (for example intersecting >>> your labels with a mask, or doing some logical operations) you inadvertently >>> produce a volume where the actual discrete values for voxles are replaced by >>> floating-point ones. What's worse is the rule of this replacement depends on >>> the data type used for the minc file, dimension order of the file and >>> particular location of the voxel within the file. >>> >>> Example: >>> >>> minccalc -express 'A[0]*2' >>> /opt/minc/share/icbm152_model_09c/mni_icbm152_t1_tal_nlin_sym_09c_deep2.mnc >>> test.mnc >>> >>> Here I take a file that contains 15 labels describing deep gray matter >>> structures and multiply each label by 2. >>> The contents of the input file (using print_all_labels): >>> Label: 1 6931 >>> Label: 2 16801 >>> Label: 3 1499 >>> Label: 4 175210 >>> Label: 5 5789 >>> Label: 6 1404 >>> Label: 7 909 >>> Label: 8 4992 >>> Label: 9 8512 >>> Label: 101 6931 >>> Label: 103 1499 >>> Label: 106 1404 >>> Label: 107 909 >>> Label: 108 4992 >>> Label: 109 8512 >>> >>> The contents of the output file : >>> Label: 2 6649 >>> *Label: 3 282* >>> Label: 4 16801 >>> Label: 6 1499 >>> Label: 8 175210 >>> Label: 10 5789 >>> Label: 12 1404 >>> Label: 14 857 >>> *Label: 15 52* >>> Label: 16 4992 >>> Label: 18 8512 >>> Label: 202 6931 >>> Label: 206 1499 >>> Label: 212 1404 >>> Label: 214 857 >>> *Label: 215 52* >>> Label: 216 4992 >>> Label: 218 8512 >>> >>> >>> Note the highlighted Labels: 3,15,215 which are clearly not possible when >>> one multiplies integer labels by 2. >>> >>> Solution (using the -labels option): >>> minccalc -labels -express 'A[0]*2' >>> /opt/minc/share/icbm152_model_09c/mni_icbm152_t1_tal_nlin_sym_09c_deep2.mnc >>> test_labels.mnc >>> >>> The output is now correct: >>> Label: 2 6931 >>> Label: 4 16801 >>> Label: 6 1499 >>> Label: 8 175210 >>> Label: 10 5789 >>> Label: 12 1404 >>> Label: 14 909 >>> Label: 16 4992 >>> Label: 18 8512 >>> Label: 202 6931 >>> Label: 206 1499 >>> Label: 212 1404 >>> Label: 214 909 >>> Label: 216 4992 >>> Label: 218 8512 >>> >>> >>> -- >>> Best regards, >>> >>> Vladimir S. FONOV ~ vladimir.fonov gmail.com >>> _______________________________________________ >>> MINC-development mailing list >>> MINC-development at bic.mni.mcgill.ca >>> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-development >> >> >> _______________________________________________ >> MINC-development mailing list >> MINC-development at bic.mni.mcgill.ca >> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-development >> > _______________________________________________ > MINC-development mailing list > MINC-development at bic.mni.mcgill.ca > http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-development Best regards, Vladimir S. FONOV ~ v.s.fonov ilmarin.info From vladimir.fonov at gmail.com Fri Mar 4 10:30:20 2016 From: vladimir.fonov at gmail.com (Vladimir S. FONOV) Date: Fri, 4 Mar 2016 10:30:20 -0500 Subject: [MINC-development] -labels support in minccalc, mincmath and mincresample In-Reply-To: References: <56D8C469.2090109@gmail.com> Message-ID: Hello, unfortunately, using -nearest_neighbour does not guarantee absence of the slice-normalization rounding error. So, one will have to use -labels -nearest to achieve the desired effect. On Thu, Mar 3, 2016 at 9:40 PM, Mishkin Derakhshan wrote: > really a great idea and very much needed for minccalc and mincmath. > for mincreseample, would this be any different than using > -nearest_neighbour? > > On Thu, Mar 3, 2016 at 2:45 PM, Andrew Janke wrote: > > ace stuff. > > > > I like it a lot. any chance we can introduce a label header tag > somewhere > > so that this happens by default for label files? > > > > I can think of a few edge cases but this should usually be right? > > > > thanks > > > > a > > > > On 04/03/2016 9:10 AM, "Vladimir S. FONOV" > wrote: > >> > >> Hello MINC developers, > >> > >> > >> I made changes to libminc ( > >> https://github.com/BIC-MNI/libminc/tree/develop-labels ) > >> > >> And minc-tools ( > https://github.com/BIC-MNI/minc-tools/tree/develop-labels > >> ) to add support for -labels option in minccalc,mincmath and > mincresample, > >> to try to address the common problem that many people seem to have over > and > >> over again and again - inter-slice normalization of volumes with integer > >> labels. > >> > >> Description of the problem: > >> > >> When you have a minc file that contains discrete levels (i.e anatomical > >> labels) produced, for example, by manual labeling in Display or > ITK-SNAP. > >> You apply some simple operation using minccalc (for example intersecting > >> your labels with a mask, or doing some logical operations) you > inadvertently > >> produce a volume where the actual discrete values for voxles are > replaced by > >> floating-point ones. What's worse is the rule of this replacement > depends on > >> the data type used for the minc file, dimension order of the file and > >> particular location of the voxel within the file. > >> > >> Example: > >> > >> minccalc -express 'A[0]*2' > >> > /opt/minc/share/icbm152_model_09c/mni_icbm152_t1_tal_nlin_sym_09c_deep2.mnc > >> test.mnc > >> > >> Here I take a file that contains 15 labels describing deep gray matter > >> structures and multiply each label by 2. > >> The contents of the input file (using print_all_labels): > >> Label: 1 6931 > >> Label: 2 16801 > >> Label: 3 1499 > >> Label: 4 175210 > >> Label: 5 5789 > >> Label: 6 1404 > >> Label: 7 909 > >> Label: 8 4992 > >> Label: 9 8512 > >> Label: 101 6931 > >> Label: 103 1499 > >> Label: 106 1404 > >> Label: 107 909 > >> Label: 108 4992 > >> Label: 109 8512 > >> > >> The contents of the output file : > >> Label: 2 6649 > >> *Label: 3 282* > >> Label: 4 16801 > >> Label: 6 1499 > >> Label: 8 175210 > >> Label: 10 5789 > >> Label: 12 1404 > >> Label: 14 857 > >> *Label: 15 52* > >> Label: 16 4992 > >> Label: 18 8512 > >> Label: 202 6931 > >> Label: 206 1499 > >> Label: 212 1404 > >> Label: 214 857 > >> *Label: 215 52* > >> Label: 216 4992 > >> Label: 218 8512 > >> > >> > >> Note the highlighted Labels: 3,15,215 which are clearly not possible > when > >> one multiplies integer labels by 2. > >> > >> Solution (using the -labels option): > >> minccalc -labels -express 'A[0]*2' > >> > /opt/minc/share/icbm152_model_09c/mni_icbm152_t1_tal_nlin_sym_09c_deep2.mnc > >> test_labels.mnc > >> > >> The output is now correct: > >> Label: 2 6931 > >> Label: 4 16801 > >> Label: 6 1499 > >> Label: 8 175210 > >> Label: 10 5789 > >> Label: 12 1404 > >> Label: 14 909 > >> Label: 16 4992 > >> Label: 18 8512 > >> Label: 202 6931 > >> Label: 206 1499 > >> Label: 212 1404 > >> Label: 214 909 > >> Label: 216 4992 > >> Label: 218 8512 > >> > >> > >> -- > >> Best regards, > >> > >> Vladimir S. FONOV ~ vladimir.fonov gmail.com > >> _______________________________________________ > >> MINC-development mailing list > >> MINC-development at bic.mni.mcgill.ca > >> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-development > > > > > > _______________________________________________ > > MINC-development mailing list > > MINC-development at bic.mni.mcgill.ca > > http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-development > > > _______________________________________________ > MINC-development mailing list > MINC-development at bic.mni.mcgill.ca > http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-development > -- Best regards, Vladimir S. Fonov ~ vladimir fonov gmail com -------------- next part -------------- An HTML attachment was scrubbed... URL: From peter.neelin at gmail.com Sat Mar 5 09:56:24 2016 From: peter.neelin at gmail.com (Peter Neelin) Date: Sat, 5 Mar 2016 09:56:24 -0500 Subject: [MINC-development] -labels support in minccalc, mincmath and mincresample In-Reply-To: <56D8C469.2090109@gmail.com> References: <56D8C469.2090109@gmail.com> Message-ID: Hallelujah!! 15 or 20 years after the need was identified. There must be a collective sigh of relief from the community! This makes me very happy from a sense of closure perspective. Thank you, Vladimir. Peter On Mar 3, 2016 18:10, "Vladimir S. FONOV" wrote: > Hello MINC developers, > > > I made changes to libminc ( > https://github.com/BIC-MNI/libminc/tree/develop-labels ) > > And minc-tools ( https://github.com/BIC-MNI/minc-tools/tree/develop-labels > ) to add support for -labels option in minccalc,mincmath and mincresample, > to try to address the common problem that many people seem to have over and > over again and again - inter-slice normalization of volumes with integer > labels. > > Description of the problem: > > When you have a minc file that contains discrete levels (i.e anatomical > labels) produced, for example, by manual labeling in Display or ITK-SNAP. > You apply some simple operation using minccalc (for example intersecting > your labels with a mask, or doing some logical operations) you > inadvertently produce a volume where the actual discrete values for voxles > are replaced by floating-point ones. What's worse is the rule of this > replacement depends on the data type used for the minc file, dimension > order of the file and particular location of the voxel within the file. > > Example: > > minccalc -express 'A[0]*2' > /opt/minc/share/icbm152_model_09c/mni_icbm152_t1_tal_nlin_sym_09c_deep2.mnc > test.mnc > > Here I take a file that contains 15 labels describing deep gray matter > structures and multiply each label by 2. > The contents of the input file (using print_all_labels): > Label: 1 6931 > Label: 2 16801 > Label: 3 1499 > Label: 4 175210 > Label: 5 5789 > Label: 6 1404 > Label: 7 909 > Label: 8 4992 > Label: 9 8512 > Label: 101 6931 > Label: 103 1499 > Label: 106 1404 > Label: 107 909 > Label: 108 4992 > Label: 109 8512 > > The contents of the output file : > Label: 2 6649 > *Label: 3 282* > Label: 4 16801 > Label: 6 1499 > Label: 8 175210 > Label: 10 5789 > Label: 12 1404 > Label: 14 857 > *Label: 15 52* > Label: 16 4992 > Label: 18 8512 > Label: 202 6931 > Label: 206 1499 > Label: 212 1404 > Label: 214 857 > *Label: 215 52* > Label: 216 4992 > Label: 218 8512 > > > Note the highlighted Labels: 3,15,215 which are clearly not possible when > one multiplies integer labels by 2. > > Solution (using the -labels option): > minccalc -labels -express 'A[0]*2' > /opt/minc/share/icbm152_model_09c/mni_icbm152_t1_tal_nlin_sym_09c_deep2.mnc > test_labels.mnc > > The output is now correct: > Label: 2 6931 > Label: 4 16801 > Label: 6 1499 > Label: 8 175210 > Label: 10 5789 > Label: 12 1404 > Label: 14 909 > Label: 16 4992 > Label: 18 8512 > Label: 202 6931 > Label: 206 1499 > Label: 212 1404 > Label: 214 909 > Label: 216 4992 > Label: 218 8512 > > > -- > Best regards, > > Vladimir S. FONOV ~ vladimir.fonov gmail.com > _______________________________________________ > MINC-development mailing list > MINC-development at bic.mni.mcgill.ca > http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-development > -------------- next part -------------- An HTML attachment was scrubbed... URL: