From sorench at gmail.com Tue Apr 14 08:42:39 2009 From: sorench at gmail.com (Soren Christensen) Date: Tue, 14 Apr 2009 22:42:39 +1000 Subject: [MINC-development] using milist_grp_next Message-ID: Hi all, Please let me know if this belongs in minc-users rather than here. I am trying to learn how to use the minc2 api but got stuck attempting to iterate through the groups and attributes of a minc2 file. Admitted my C skills need a little work too, that may well be the problem. I am building on one of the tutorials and get an error from the below code: #include #include int main(int argc, char **argv) { mihandle_t minc_volume; milisthandle_t milisthandle; int result; char mystr[255]; int maxpath; result = miopen_volume(argv[1], MI2_OPEN_READ, &minc_volume); if (result != MI_NOERROR) { fprintf(stderr, "Error opening input file: %d.\n", result); } result = milist_start ( minc_volume,"/",1,&milisthandle); if (result != MI_NOERROR) { fprintf(stderr, "Error querying input file: %d.\n", result); } result = milist_grp_next (milisthandle, mystr,maxpath); if (result != MI_NOERROR) { fprintf(stderr, "Error in reading group: %d.\n", result); } return(0); } ./prog minc2.mnc gives: HDF5-DIAG: Error detected in HDF5 library version: 1.6.1 thread 0. Back trace follows. #000: H5G.c line 296 in H5Gopen(): unable to open group major(10): Symbol table layer minor(52): Can't open object #001: H5G.c line 1888 in H5G_open(): not found major(10): Symbol table layer minor(40): Object not found #002: H5G.c line 1945 in H5G_open_oid(): not a group major(10): Symbol table layer minor(52): Can't open object #003: H5O.c line 1467 in H5O_read(): unable to load object header major(12): Object header layer minor(22): Read failed #004: H5O.c line 1528 in H5O_read_real(): unable to find message in object header major(12): Object header layer minor(40): Object not found #005: H5O.c line 1609 in H5O_find_in_ohdr(): unable to find object header message major(12): Object header layer minor(40): Object not found Could someone give me a hint as to what I am doing wrong? From what I can see in the unit test the syntax seems much the same. Thanks in advance, Soren The file should be ok btw: h5dump -H minc2.mnc | grep 'GROUP\|DATASET' GROUP "/" { GROUP "minc-2.0" { GROUP "dimensions" { DATASET "xspace" { DATASET "yspace" { DATASET "zspace" { GROUP "image" { GROUP "0" { DATASET "image" { DATASET "image-max" { DATASET "image-min" { GROUP "info" { DATASET "dicom_0x0002" { DATASET "dicom_0x0008" { DATASET "dicom_0x0010" { DATASET "dicom_0x0018" { DATASET "dicom_0x0019" { DATASET "dicom_0x0020" { DATASET "dicom_0x0028" { DATASET "dicom_0x0040" { DATASET "study" { From baghdadi at phenogenomics.ca Tue Apr 14 10:34:10 2009 From: baghdadi at phenogenomics.ca (Leila Baghdadi) Date: Tue, 14 Apr 2009 10:34:10 -0400 Subject: [MINC-development] using milist_grp_next In-Reply-To: References: Message-ID: <1239719652.24458.20.camel@mouse30.phenogenomics.ca> An embedded and charset-unspecified text was scrubbed... Name: not available Url: http://www2.bic.mni.mcgill.ca/pipermail/minc-development/attachments/20090414/b50e2732/attachment.txt From sorench at gmail.com Wed Apr 15 04:07:59 2009 From: sorench at gmail.com (Soren Christensen) Date: Wed, 15 Apr 2009 18:07:59 +1000 Subject: [MINC-development] using milist_grp_next In-Reply-To: <1239719652.24458.20.camel@mouse30.phenogenomics.ca> References: <1239719652.24458.20.camel@mouse30.phenogenomics.ca> Message-ID: Hi Leila, Thanks very much for your help, good to know the code is ok. I used the HDF in the tgz folder with the other sources. That has not given any problems with the core tools so far (eg mincinfo and resample work fine). Can the 1.6.1 be the issue despite that? I installed HDF 1.6.5 but now get a warning that Headers are 1.6.1, library is 1.6.5. I am not sure what the problem here is? Is it because MINC is build with HDF 1.6.1 in a static build? I am trying to make sure that the 1.6.1 headers are not used when I compile the test program (1.6.1 is not in /usr/local/lib but in a seperate folder): Cheers Soren compiling: gcc -o prog -I/usr/local/hdf5-1.6.5/include -L/usr/local/hdf5-1.6.5/lib -L/usr/local/mni2/lib -I/usr/local/mni2/include/ minc2.c -lminc2 -lhdf5 -lnetcdf env LD_LIBRARY_PATH=/usr/local/hdf5-1.6.5/lib Libraries used are 1.6.5 ldd prog linux-gate.so.1 => (0x008ac000) libhdf5.so.0 => /usr/local/hdf5-1.6.5/lib/libhdf5.so.0 (0x0014b000) libc.so.6 => /lib/libc.so.6 (0x006a6000) libm.so.6 => /lib/libm.so.6 (0x0081c000) libz.so.1 => /lib/libz.so.1 (0x00888000) /lib/ld-linux.so.2 (0x0067d000) On Wed, Apr 15, 2009 at 12:34 AM, Leila Baghdadi wrote: > soren, > > the code seems to be fine, but you are using hdf5 1.6.1 last I checked > we were using 1.6.5 unless Andrew has rolled up his sleeves and made all > necessary changes for the new hdf5 (which I think are too many), > > Leila > > On Tue, 2009-04-14 at 22:42 +1000, Soren Christensen wrote: >> Hi all, >> Please let me know if this belongs in minc-users rather than here. >> ?I am trying to learn how to use the minc2 api but got stuck >> attempting to iterate through the groups and attributes of a minc2 >> file. Admitted my C skills need a little work too, that may well be >> the problem. >> I am building on one of the tutorials and get an error from the below code: >> >> #include >> #include >> >> int main(int argc, char **argv) { >> ? mihandle_t ? ?minc_volume; >> ? milisthandle_t milisthandle; >> ? int ? ? ? ? ? result; >> ? char ? ? ? ? ?mystr[255]; >> ? int ? ? ? ? ? maxpath; >> >> ? result = miopen_volume(argv[1], MI2_OPEN_READ, &minc_volume); >> >> ? if (result != MI_NOERROR) { >> ? ? fprintf(stderr, "Error opening input file: %d.\n", result); >> ? } >> >> ? result = milist_start ( minc_volume,"/",1,&milisthandle); >> >> ? if (result != MI_NOERROR) { >> ? ? fprintf(stderr, "Error querying input file: %d.\n", result); >> ? } >> >> ? result = milist_grp_next ?(milisthandle, mystr,maxpath); >> >> ? if (result != MI_NOERROR) { >> ? ? fprintf(stderr, "Error in reading group: %d.\n", result); >> ? } >> >> >> >> ? return(0); >> } >> >> >> >> ./prog minc2.mnc >> >> gives: >> HDF5-DIAG: Error detected in HDF5 library version: 1.6.1 thread 0. >> Back trace follows. >> ? #000: H5G.c line 296 in H5Gopen(): unable to open group >> ? ? major(10): Symbol table layer >> ? ? minor(52): Can't open object >> ? #001: H5G.c line 1888 in H5G_open(): not found >> ? ? major(10): Symbol table layer >> ? ? minor(40): Object not found >> ? #002: H5G.c line 1945 in H5G_open_oid(): not a group >> ? ? major(10): Symbol table layer >> ? ? minor(52): Can't open object >> ? #003: H5O.c line 1467 in H5O_read(): unable to load object header >> ? ? major(12): Object header layer >> ? ? minor(22): Read failed >> ? #004: H5O.c line 1528 in H5O_read_real(): unable to find message in >> object header >> ? ? major(12): Object header layer >> ? ? minor(40): Object not found >> ? #005: H5O.c line 1609 in H5O_find_in_ohdr(): unable to find object >> header message >> ? ? major(12): Object header layer >> ? ? minor(40): Object not found >> >> >> >> Could someone give me a hint as to what I am doing wrong? From what I >> can see in the unit test the syntax seems much the same. >> >> >> Thanks in advance, >> Soren >> >> >> The file should be ok btw: >> h5dump -H minc2.mnc ?| grep 'GROUP\|DATASET' >> GROUP "/" { >> ? ?GROUP "minc-2.0" { >> ? ? ? GROUP "dimensions" { >> ? ? ? ? ?DATASET "xspace" { >> ? ? ? ? ?DATASET "yspace" { >> ? ? ? ? ?DATASET "zspace" { >> ? ? ? GROUP "image" { >> ? ? ? ? ?GROUP "0" { >> ? ? ? ? ? ? DATASET "image" { >> ? ? ? ? ? ? DATASET "image-max" { >> ? ? ? ? ? ? DATASET "image-min" { >> ? ? ? GROUP "info" { >> ? ? ? ? ?DATASET "dicom_0x0002" { >> ? ? ? ? ?DATASET "dicom_0x0008" { >> ? ? ? ? ?DATASET "dicom_0x0010" { >> ? ? ? ? ?DATASET "dicom_0x0018" { >> ? ? ? ? ?DATASET "dicom_0x0019" { >> ? ? ? ? ?DATASET "dicom_0x0020" { >> ? ? ? ? ?DATASET "dicom_0x0028" { >> ? ? ? ? ?DATASET "dicom_0x0040" { >> ? ? ? ? ?DATASET "study" { >> _______________________________________________ >> MINC-development mailing list >> MINC-development at bic.mni.mcgill.ca >> http://www2.bic.mni.mcgill.ca/mailman/listinfo/minc-development > > _______________________________________________ > MINC-development mailing list > MINC-development at bic.mni.mcgill.ca > http://www2.bic.mni.mcgill.ca/mailman/listinfo/minc-development > From baghdadi at phenogenomics.ca Wed Apr 15 10:28:24 2009 From: baghdadi at phenogenomics.ca (Leila Baghdadi) Date: Wed, 15 Apr 2009 10:28:24 -0400 Subject: [MINC-development] using milist_grp_next In-Reply-To: References: Message-ID: <1239805704.30290.2.camel@mouse30.phenogenomics.ca> An embedded and charset-unspecified text was scrubbed... Name: not available Url: http://www2.bic.mni.mcgill.ca/pipermail/minc-development/attachments/20090415/adfbae6e/attachment.txt From claude at bic.mni.mcgill.ca Tue Apr 21 17:04:50 2009 From: claude at bic.mni.mcgill.ca (Claude LEPAGE) Date: Tue, 21 Apr 2009 17:04:50 -0400 Subject: [MINC-development] minc2 compression - another bug under control Message-ID: <200904212104.n3LL4oNK000376@grumio.bic.mni.mcgill.ca> Hi, I isolated a bug about internal file compression in minc2. The bug is fixed, but hasn't made it to cvs just yet (it will soon be). The problem occurred when writing large volumes. For example, I had a volume 361x433x361 (0.5mm) that would take 90 minutes to write to disk. Painfully slow. After my fix, it takes 13 seconds to write the file. The fix also has a positive effects with 4-D volumes. Unfortunately, I haven't solved the problem of compression when dimensions are reordered (mincreshape). If you want to fix your local version of minc2 before the next release, then change the following piece of code in libsrc/hdf_convenience.c: New code should look like (line 1345): hsize_t val = 1; int unit_size = nctypelen( vartype ); for( i = ndims-1; i >= 0; i-- ) { if( MI_MAX_VAR_BUFFER_SIZE > dims[i] * val * unit_size ) { chkdims[i] = dims[i]; } else { chkdims[i] = MIN( dims[i], (hsize_t)( MI_MAX_VAR_BUFFER_SIZE / ( val * unit_size ) ) ); } val *= chkdims[i]; } Notice the placement of the update of the variable val. Enjoy! Claude From a.janke at gmail.com Tue Apr 21 19:07:04 2009 From: a.janke at gmail.com (Andrew Janke) Date: Wed, 22 Apr 2009 09:07:04 +1000 Subject: [MINC-development] minc2 compression - another bug under control In-Reply-To: <200904212104.n3LL4oNK000376@grumio.bic.mni.mcgill.ca> References: <200904212104.n3LL4oNK000376@grumio.bic.mni.mcgill.ca> Message-ID: > If you want to fix your local version of minc2 before the next > release, then change the following piece of code in > libsrc/hdf_convenience.c: > > Notice the placement of the update of the variable val. Ah.... yes I can see that being a _slight_ problem. I have changed my own version here and it works well. Almost reason enough to turn compression back on. :) Thanks a