Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ecat7 pet scans aborted conversion #95

Closed
cbedetti opened this issue Apr 25, 2017 · 9 comments
Closed

ecat7 pet scans aborted conversion #95

cbedetti opened this issue Apr 25, 2017 · 9 comments

Comments

@cbedetti
Copy link

I'm converting ecat7 pet scans files. dcm2nii convert my files without error.

Here is the output with dcm2niix build from this version:

commit 52f76cc896b17b86b74b01d77ec59e0454fc0886
Author: Ningfei Li <ningfei.li@gmail.com>
Date:   Tue Apr 25 22:18:39 2017 +0200
Chris Rorden's dcm2niiX version v1.0.20170411 GCC4.4.7 (64-bit Linux)
--> /XXX/scans/XXXXX/XXX.v
Only reading first volume from ECAT file with 6 frames and 0 bed positions
*** glibc detected *** dcm2niix: double free or corruption (top): 0x0000000002626010 ***
======= Backtrace: =========
/lib64/libc.so.6[0x3b95675f4e]
/lib64/libc.so.6[0x3b95678cf0]
/lib64/libc.so.6(fclose+0x14d)[0x3b956664cd]
dcm2niix(_Z13nii_readEcat7PKcP14nifti_1_headerPb+0x468)[0x41a0f8]
dcm2niix(open_foreign+0x2d)[0x41a1ed]
dcm2niix(nii_loadDir+0xa57)[0x4339e7]
dcm2niix(main+0x264)[0x405594]
/lib64/libc.so.6(__libc_start_main+0xfd)[0x3b9561ed5d]
dcm2niix[0x405089]
======= Memory map: ========
00400000-0043c000 r-xp 00000000 00:19 525162                             /sf1/project/XXX/local/dcm2niix/git/bin/dcm2niix
0063b000-0063c000 rw-p 0003b000 00:19 525162                             /sf1/project/XXX/local/dcm2niix/git/bin/dcm2niix
0063c000-006bc000 rw-p 00000000 00:00 0 
02626000-02647000 rw-p 00000000 00:00 0                                  [heap]
3b95200000-3b95220000 r-xp 00000000 08:06 1966146                        /lib64/ld-2.12.so
3b9541f000-3b95420000 r--p 0001f000 08:06 1966146                        /lib64/ld-2.12.so
3b95420000-3b95421000 rw-p 00020000 08:06 1966146                        /lib64/ld-2.12.so
3b95421000-3b95422000 rw-p 00000000 00:00 0 
3b95600000-3b9578a000 r-xp 00000000 08:06 1966147                        /lib64/libc-2.12.so
3b9578a000-3b9598a000 ---p 0018a000 08:06 1966147                        /lib64/libc-2.12.so
3b9598a000-3b9598e000 r--p 0018a000 08:06 1966147                        /lib64/libc-2.12.so
3b9598e000-3b9598f000 rw-p 0018e000 08:06 1966147                        /lib64/libc-2.12.so
3b9598f000-3b95994000 rw-p 00000000 00:00 0 
3b95e00000-3b95e83000 r-xp 00000000 08:06 1966148                        /lib64/libm-2.12.so
3b95e83000-3b96082000 ---p 00083000 08:06 1966148                        /lib64/libm-2.12.so
3b96082000-3b96083000 r--p 00082000 08:06 1966148                        /lib64/libm-2.12.so
3b96083000-3b96084000 rw-p 00083000 08:06 1966148                        /lib64/libm-2.12.so
3b9f600000-3b9f616000 r-xp 00000000 08:06 1966157                        /lib64/libgcc_s-4.4.7-20120601.so.1
3b9f616000-3b9f815000 ---p 00016000 08:06 1966157                        /lib64/libgcc_s-4.4.7-20120601.so.1
3b9f815000-3b9f816000 rw-p 00015000 08:06 1966157                        /lib64/libgcc_s-4.4.7-20120601.so.1
3b9fa00000-3b9fae8000 r-xp 00000000 08:06 9853758                        /usr/lib64/libstdc++.so.6.0.13
3b9fae8000-3b9fce8000 ---p 000e8000 08:06 9853758                        /usr/lib64/libstdc++.so.6.0.13
3b9fce8000-3b9fcef000 r--p 000e8000 08:06 9853758                        /usr/lib64/libstdc++.so.6.0.13
3b9fcef000-3b9fcf1000 rw-p 000ef000 08:06 9853758                        /usr/lib64/libstdc++.so.6.0.13
3b9fcf1000-3b9fd06000 rw-p 00000000 00:00 0 
2b5cf1c58000-2b5cf1c59000 rw-p 00000000 00:00 0 
2b5cf1c7b000-2b5cf1c82000 rw-p 00000000 00:00 0 
2b5cf4000000-2b5cf4021000 rw-p 00000000 00:00 0 
2b5cf4021000-2b5cf8000000 ---p 00000000 00:00 0 
7fffe227f000-7fffe22a1000 rw-p 00000000 00:00 0                          [stack]
7fffe2392000-7fffe2393000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
Aborted

Not sure what's wrong here

@cbedetti cbedetti changed the title ecat7 pet scans aborted convertion ecat7 pet scans aborted conversion Apr 25, 2017
@ningfei
Copy link
Collaborator

ningfei commented Apr 26, 2017

Hi cbedetti, did dcm2niix from this commit 3f2d477 work for you?

@ningfei
Copy link
Collaborator

ningfei commented Apr 26, 2017

The double free or corruption error has just been fixed. But it's still not ready to convert ecat7 images, since convertForeignToNifti is not implemented yet, only hdr is read so far.

@neurolabusc
Copy link
Collaborator

dcm2niix does not support ECAT7. The master development branch has some code which attempts to read the ECAT header, as part of an experimental attempt to read ECAT7. For the moment, you can use either the legacy dcm2nii or SPM12 to convert ECAT to NIfTI. However, be aware that neither of those tools convert the spatial transform (SForm). This means that spatial orientation may be wrong and different scans from the same session may not be aligned with each other. ECAT is a proprietary format, and it is unclear to me if we can fully support conversion to the NIfTI standard. Can your system also export to DICOM? If so, I would suggest following that route.

@cbedetti
Copy link
Author

With the last version (dfce355), I have this message now ECAT images not yet supported ^^

I tried 3f2d477 and still have double free or corruption error.

I know DICOM would be better but in this case it's not possible. To be more precise, dcm2nii is successful in creating the NIfTI file but I still need to manually crop, transform 3D to 4D... So I tried dcm2niix !

If you plan to go futher with ECAT images, I would be happy to give feedbacks with the data I have.

@neurolabusc
Copy link
Collaborator

You can try the latest build, but this is a feature I have just started working on. As I mentioned previously, for at least the near term I would recommend using SPM12 or dcm2nii. After further exploration, it seems like ECAT files do not fill in their "matrix" parameters, so it is impossible to accurately gauge the spatial orientation. I do not have access to an ECAT machine, but I would suggest that you work with your vendor to have them support a well documented format (NIfTI or DICOM) directly. The ECAT format as generated is simply underspecified to create a good NIfTI image.

In terms of your manually cropping and transforming from 3D to 4D, you may want to look at my Matlab scripts that use SPM12 to crop images - it might take a bit of tweaking for your data, but this should allow you to integrate all the steps.
https://github.com/rordenlab/spmScripts/blob/master/nii_setOrigin12x.m

@neurolabusc
Copy link
Collaborator

neurolabusc commented Apr 28, 2017

I have added experimental support for ECAT to dcm2niix v1.0.20170428, perhaps @chrisfilo and @cbedetti can try this out. I do have a few comments:
1.) ECAT files do not appear to store series numbers, so think carefully about how you specify the output filename (using -f), for the OASIS data, I have found ./dcm2niix -f %n_%i -b n -v y ~/ECAT/ works pretty well.
2.) None of the ECAT files I have seen fill out the spatial transformation matrix, so I simply cloned SPM's approach for this. I do think it might be useful to ensure we are never flipping any dimensions (especially left-right flips).
3.) ECAT images can report separate scl_slopes for every volume in a 4D series. This is not possible for NIfTI 4D data. SPM12's solution is to save each volume as a separate 3D file. My solution is to convert the 16-bit data to 32-bit float and save the scaled image data. While my solution does create a single file and preserve precision, these files require twice as much disk space. I only do this if the scl_slope varies, so in theory some datasets will be converted to their native 16-bit and others will be saved as 32-bit.
4.) I have added a few preliminary BIDS features. Maybe someone who knows more about these modalities can attempt to support the proposed BIDS PET extension. Matlab users will find Flemming Hermansen's ecatfile.m an easy way to explore ECAT headers. In addition, developers and users may want to check out the dedicated ecat2nii.

@cbedetti
Copy link
Author

Thank you for all the feed back and implementation you've done.

Just a minor bug. When I give several directories to dcm2niix, if one of the directory has only ECAT file, I get an error. The ECAT file is converted but dcm2niix won't look into the other directories even if there is DICOMs.

$ dcm2niix -b y -ba y -z y -f '%f_%p_%t_%s' -o tmp_dcm2bids/dcm2niix-example/ sourcedata/${sub}/*v00*/
Chris Rorden's dcm2niiX version v1.0.20170429 GCC4.4.7 (64-bit Linux)
Warning: ECAT support VERY experimental (Spatial transforms unknown)
Saving ECAT as 'tmp_dcm2bids/dcm2niix-example/${sub}_v00_*'
compress: "/usr/bin/pigz" -n -f "tmp_dcm2bids/dcm2niix-example/${sub}_v00_*.nii"
Error: Unable to find any DICOM images in sourcedata/${sub}/${sub}_v00_fdg

It's really easy to get around with iteration though.

@neurolabusc
Copy link
Collaborator

I can not replicate your error. Are you sure there are DICOM files in the other folders and that the expansion for the ${sub} value is correct - in other words does it find the DICOM files if you explicitly provide a root folder that contains both DICOM and ECAT files. Below is my attempt to replicate your issue, where the root folder ~\tst_t1 contains both ECAT images (in ~\tst_t1\ECAT) as well as DICOM images (in ~\tst_t1\T1_simple_rorden)

./dcm2niix -b y -ba y -z y -f '%f_%p_%t_%s' -o ~/tst ~/tst_t1
Chris Rorden's dcm2niiX version v1.0.20170429 GCC6.1.0 (64-bit MacOS)
Warning: ECAT support VERY experimental (Spatial transforms unknown)
Saving ECAT as '/Users/rorden/tst/tst_t1__19770703150928_1'
compress: "/usr/local/bin/pigz" -n -f "/Users/rorden/tst/tst_t1__19770703150928_1.nii"
Warning: ECAT support VERY experimental (Spatial transforms unknown)
Saving ECAT as '/Users/rorden/tst/tst_t1_OAS30001_PIB_19770703150928_1'
compress: "/usr/local/bin/pigz" -n -f "/Users/rorden/tst/tst_t1_OAS30001_PIB_19770703150928_1.nii"
Found 176 DICOM image(s)
Convert 176 DICOM as /Users/rorden/tst/tst_t1__tfl3d1_ns_20080617133857_2 (256x256x176x1)
compress: "/usr/local/bin/pigz" -n -f "/Users/rorden/tst/tst_t1__tfl3d1_ns_20080617133857_2.nii"
Conversion required 1.341202 seconds (0.282014 for core code).

@cbedetti
Copy link
Author

I was in a case where my script gave several input directories to dcm2niix with :
./dcm2niix -b y -ba y -z y -f '%f_%p_%t_%s' -o ~/tst ~/tst_v00_*
expand to
./dcm2niix -b y -ba y -z y -f '%f_%p_%t_%s' -o ~/tst ~/tst_v00_fdg ~/tst_v00_mr

Sorry about that, it was a PEBKAC bug ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants