Code Monkey home page Code Monkey logo

spec2nii's People

Contributors

agudmundson avatar alexcraven avatar clemoune avatar dc-3t avatar dimitripapadopoulos avatar hfxcarl avatar marcelzwiers avatar markmikkelsen avatar musicinmybrain avatar neutralkaon avatar tomas-psorn avatar wtclarke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

spec2nii's Issues

Philips SDAT + SPAR don't create final nifti

Currently running it on windows. I tried to convert philips SDAT and SPAR into nifit. It prompts me saying the "Header Extension is Validated", however, no nifti file actually is generated.

spec2niiscreenshott

Question regarding dicom converter

Hi,

I'm looking into replacing my FID-A twix based processing pipelines with a FID-A dicom based one which is what brought me here. Seems like a very useful and growing project.

I do have some questions about how best to do these conversions to seamlessly slot into what I currently have but first wanted to know if there is discussion forum for questions or if I should just use this issue?

Thanks!
Luke

spec2nii does not support raw data from United Imaging Healthcare(UIH)

UIH is a MR manufacturer from China, and by now many institutes over the world have been using UIH MR scanners to acquire MRI data. However, the spec2nii currently does not support MRS raw data conversion obtained from UIH scanners.
What information is required for MRS data format conversion? Maybe, I can provide some support to implement UIH data conversion. If and questions, please give me a reply or contact me via email [email protected]

Conversion failure on GE data

I am getting a conversion failure on GE MRS data - the command line and backtrace are below, however the root cause seems to be zeros in one column of the affine matrix. If I print out the calculated affine I get:

[[-22.80869862   0.          -3.10708493 -31.39293289]
 [ 11.13030002   0.          22.59598556  53.63864517]
 [ 15.99623983   0.         -20.15277751  29.13773346]
 [  0.           0.           0.           1.        ]]

Any ideas what might be going wrong, and whether there's any way to work around this?
Many thanks,
Martin

spec2nii ge -o mrs_mask -f mrs_data -j P03072.7

/home/bbzmsc/.conda/envs/brightmind/lib/python3.10/site-packages/nibabel/nifti1.py:1088: RuntimeWarning: invalid value encountered in divide
  R = RZS / zooms
/home/bbzmsc/.conda/envs/brightmind/lib/python3.10/site-packages/numpy/linalg/linalg.py:2180: RuntimeWarning: invalid value encountered in det
  r = _umath_linalg.det(a, signature=signature)
Traceback (most recent call last):
  File "/home/bbzmsc/.conda/envs/brightmind/bin/spec2nii", line 10, in <module>
    sys.exit(main())
  File "/home/bbzmsc/.conda/envs/brightmind/lib/python3.10/site-packages/spec2nii/spec2nii.py", line 679, in main
    spec2nii(*args)
  File "/home/bbzmsc/.conda/envs/brightmind/lib/python3.10/site-packages/spec2nii/spec2nii.py", line 290, in __init__
    args.func(args)
  File "/home/bbzmsc/.conda/envs/brightmind/lib/python3.10/site-packages/spec2nii/spec2nii.py", line 628, in ge
    self.imageOut, self.fileoutNames = read_pfile(args.file, args.fileout)
  File "/home/bbzmsc/.conda/envs/brightmind/lib/python3.10/site-packages/spec2nii/GE/ge_pfile.py", line 71, in read_pfile
    data, fname_suffix = _process_svs_pfile(pfile)
  File "/home/bbzmsc/.conda/envs/brightmind/lib/python3.10/site-packages/spec2nii/GE/ge_pfile.py", line 113, in _process_svs_pfile
    out_nmrs.append(gen_nifti_mrs_hdr_ext(dd, dwelltime, mm, orientation.Q44, no_conj=True))
  File "/home/bbzmsc/.conda/envs/brightmind/lib/python3.10/site-packages/nifti_mrs/create_nmrs.py", line 128, in gen_nifti_mrs_hdr_ext
    tmp_img = nib.nifti2.Nifti2Image(
  File "/home/bbzmsc/.conda/envs/brightmind/lib/python3.10/site-packages/nibabel/nifti1.py", line 1848, in __init__
    super().__init__(dataobj, affine, header, extra, file_map, dtype)
  File "/home/bbzmsc/.conda/envs/brightmind/lib/python3.10/site-packages/nibabel/analyze.py", line 909, in __init__
    super().__init__(dataobj, affine, header, extra, file_map)
  File "/home/bbzmsc/.conda/envs/brightmind/lib/python3.10/site-packages/nibabel/spatialimages.py", line 531, in __init__
    self.update_header()
  File "/home/bbzmsc/.conda/envs/brightmind/lib/python3.10/site-packages/nibabel/nifti1.py", line 2273, in update_header
    super().update_header()
  File "/home/bbzmsc/.conda/envs/brightmind/lib/python3.10/site-packages/nibabel/nifti1.py", line 1884, in update_header
    super().update_header()
  File "/home/bbzmsc/.conda/envs/brightmind/lib/python3.10/site-packages/nibabel/spatialimages.py", line 565, in update_header
    self._affine2header()
  File "/home/bbzmsc/.conda/envs/brightmind/lib/python3.10/site-packages/nibabel/nifti1.py", line 1894, in _affine2header
    hdr.set_qform(self._affine, code='unknown')
  File "/home/bbzmsc/.conda/envs/brightmind/lib/python3.10/site-packages/nibabel/nifti1.py", line 1100, in set_qform
    P, S, Qs = npl.svd(R)
  File "/home/bbzmsc/.conda/envs/brightmind/lib/python3.10/site-packages/numpy/linalg/linalg.py", line 1681, in svd
    u, s, vh = gufunc(a, signature=signature, extobj=extobj)
  File "/home/bbzmsc/.conda/envs/brightmind/lib/python3.10/site-packages/numpy/linalg/linalg.py", line 121, in _raise_linalgerror_svd_nonconvergence
    raise LinAlgError("SVD did not converge")
numpy.linalg.LinAlgError: SVD did not converge

Support for Philips MEGA-PRESS dicom

Trying to convert mega-press data in dicom format currently produces the following error:

Traceback (most recent call last): File "C:\Users\Jonpe389\Anaconda3\Scripts\spec2nii-script.py", line 9, in <module> sys.exit(main()) File "C:\Users\Jonpe389\Anaconda3\lib\site-packages\spec2nii\spec2nii.py", line 664, in main spec2nii(*args) File "C:\Users\Jonpe389\Anaconda3\lib\site-packages\spec2nii\spec2nii.py", line 281, in __init__ args.func(args) File "C:\Users\Jonpe389\Anaconda3\lib\site-packages\spec2nii\spec2nii.py", line 607, in philips_dicom self.imageOut, self.fileoutNames = multi_file_dicom(files_in, args.fileout, args.tag, args.verbose) File "C:\Users\Jonpe389\Anaconda3\lib\site-packages\spec2nii\Philips\philips_dcm.py", line 79, in multi_file_dicom mrs_type = svs_or_CSI(img) File "C:\Users\Jonpe389\Anaconda3\lib\site-packages\spec2nii\Philips\philips_dcm.py", line 39, in svs_or_CSI if _is_new_format(img): File "C:\Users\Jonpe389\Anaconda3\lib\site-packages\spec2nii\Philips\philips_dcm.py", line 34, in _is_new_format raise ValueError(f'Media Storage SOP Class UID {media_storage_class} not recognised as spectroscopy.') ValueError: Media Storage SOP Class UID 1.3.46.670589.11.0.0.12.2 not recognised as spectroscopy.

Unfortunately for some measurements I do not have data in SPAR/SDAT format so support for this would be tremendously helpful.

The dicom data seems to be one file per spectrum and looking through the header, it seems that the actual data is stored in '2005','1270'.

I can provide example data in both dicom and SPAR/SDAT for the same measurement if it is possible to share privately.

AttributeError: 'PosixPath' object has no attribute 'lower'

$ spec2nii dicom my-input-file.dcm
Traceback (most recent call last):
  File "/cm/shared/anaconda3/bin/spec2nii", line 10, in <module>
    sys.exit(main())
  File "/cm/shared/anaconda3/lib/python3.9/site-packages/spec2nii/spec2nii.py", line 485, in main
    spec2nii(*args)
  File "/cm/shared/anaconda3/lib/python3.9/site-packages/spec2nii/spec2nii.py", line 247, in __init__
    args.func(args)
  File "/cm/shared/anaconda3/lib/python3.9/site-packages/spec2nii/spec2nii.py", line 466, in anon
    self.imageOut, self.fileoutNames = anon_nifti_mrs(args)
  File "/cm/shared/anaconda3/lib/python3.9/site-packages/spec2nii/anonymise.py", line 27, in anon_nifti_mrs
    nifti_mrs_img = nib.load(args.file)
  File "/cm/shared/anaconda3/lib/python3.9/site-packages/nibabel/loadsave.py", line 47, in load
    is_valid, sniff = image_klass.path_maybe_image(filename, sniff)
  File "/cm/shared/anaconda3/lib/python3.9/site-packages/nibabel/filebasedimages.py", line 499, in path_maybe_image
    froot, ext, trailing = splitext_addext(filename,
  File "/cm/shared/anaconda3/lib/python3.9/site-packages/nibabel/filename_parser.py", line 265, in splitext_addext
    if endswith(filename, ext):
  File "/cm/shared/anaconda3/lib/python3.9/site-packages/nibabel/filename_parser.py", line 223, in _iendswith
    return whole.lower().endswith(end.lower())
AttributeError: 'PosixPath' object has no attribute 'lower'

Pixel dimensions in TWIX data

Hello Will,

I've been working on NFTI MRS voxel/structural co-registration using NIfTI MRS data generated by your amazing tool. I've been able to get this working for Philips data. However, I encountered an issue in the dimensions of the NIfTI generated from TWIX data. While the slice dimension is correctly parsed, it appears that the read/phase dimensions aren't. I had a look at the TWIX data using mapVBVD and it looks like the dimensions parsed might be:
[twix_obj.hdr.Config.RoFOV, twix_obj.hdr.Config.PhaseFoV, twix_obj.hdr.Config.VoI_SliceThickness]
rather than:
[twix_obj.hdr.Config.VoI_RoFOV, twix_obj.hdr.Config.VoI_PeFOV, twix_obj.hdr.Config.VoI_SliceThickness]

If I've overlooked something in spec2nii, then I'd really appreciate a shove in the right direction, but just wanted to raise this issue with you.

Thanks,
Chris

BIDscoin spec2nii2bids plugin development

This is not really an issue but an open invitation for anyone interested in participating in (or taking over if you like) the development of the spec2nii2bids plugin in BIDScoin. This plugin is merely a wrapper around spec2nii, to abstract away the file format specifics for BIDScoin. In this way, MRS data for BIDScoin is like any other data, allowing it to do automatic data discovery and present a GUI to the user for further editing of the BIDS output (if desired).

The reason I'm reaching out here is that I myself don't have any experience with / much knowledge about MRS, and I just wrote the plugin to help out with a multi-site project (LEAP) of one of my colleagues. For that, I only implemented support for SPAR, Twix, and Pfile data (i.e. the data formats collected in the project). Of course, it would be nice to extend that to all the formats supported by spec2nii, but I don't have access to nor experience with all those formats.

If you are interested, here's the plugin (adding a data format is very easy):
https://github.com/Donders-Institute/bidscoin/blob/master/bidscoin/plugins/spec2nii2bids.py

And here is the template bidsmap (adding a new data format section here isn't hard, but it contains prior knowledge for all the BIDS data types, so it is a bit long):
https://github.com/Donders-Institute/bidscoin/blob/master/bidscoin/heuristics/bidsmap_dccn.yaml

That's all there is to it. For more info about BIDScoin, see the (latest) docs:
https://bidscoin.readthedocs.io/en/latest/

Cheers,
Marcel

"spectral width" field not stored in nii header extension

Hi Will,

One more thing: my Philips SPAR/SDAT data have the dwell time correctly stored in the 5-th pixdim element, however, the "spectral width" metadata field is not written out explicitly in the header extension or the json sidecar, although it is a mandatory metadata field according to the BEP (https://bids-specification.readthedocs.io/en/bep022/modality-specific-files/magnetic-resonance-spectroscopy.html#mrs-specific-fields).

Thanks :)
Georg

Convert Siemens CSI from Twix or RDA

๐Ÿ‘‹ @wtclarke,

I've used spec2nii to convert SVS and I really appreciate the usefulness of the tool, it's amazing thanks!

I've got access to CSI/MRSI data acquired on a Prisma (VD/VE IIRC) and I know it's not (yet) available for Twix and RDA data. Unfortunately, I only have the Twix and RDA, but not the dicoms. I've seen your message (spec2nii.Siemens.rda.MRSINotHandledError: MRSI is currently not handled in the RDA format. Test data needed.) and I could share some in private. I have both RDA and Twix of the same data.

It is probably not an easy (and quick?) feature to implement but I'd happily work on that feature if you are willing to give me some pointers to get me started.

Thanks

spec2nii twix generates stderr

Running spec2nii twix runs without error (i.e. with error code / exit status = 0):

spec2nii twix -j -f "sub-mrssiemens_run-2_press" -o "/home/mrphys/marzwi/mridata/spec2nii2bids/bids/sub-mrssiemens/mrs"  -e image "/home/mrphys/marzwi/mridata/spec2nii2bids/raw/sub-mrssiemens/water/HERMES/sub-220182106_thal_wat.dat"
pymapVBVD version 0.4.3
Software version: VD
Converting twix file /home/mrphys/marzwi/mridata/spec2nii2bids/raw/sub-mrssiemens/water/HERMES/sub-220182106_thal_wat.dat.
Looking for evalinfo flag image.
Found data of size (4096, 32, 16).
Header extension validated!

However, it outputs statistics output on stderr:

Scan 1/2, read all mdhs:   0%|          | 0.00/60.7M [00:00<?, ?B/s]
                                                                    
Scan 2/2, read all mdhs:   0%|          | 0.00/66.0M [00:00<?, ?B/s]
                                                                    
read data:   0%|          | 0/65 [00:00<?, ?it/s]
read data:  22%|???       | 14/65 [00:00<00:00, 111.17it/s]
read data:  46%|?????     | 30/65 [00:00<00:00, 131.76it/s]
read data:  95%|??????????| 62/65 [00:00<00:00, 136.18it/s]

This is of course not a big problem, but I believe it is not good practice (and it provokes a warning in the (unreleased/experimental) spec2nii plugin I wrote for my BIDScoin application)

TypeError: '>' not supported between instances of 'str' and 'int' during TWIX conversion

I'm triyng to convert a TWIX file from a 7T scanner, but spec2nii fails with the error in the object.

spec2nii twix -v sub-701_nuc-1H_loc-pcc_spec-lr-special.dat 
pymapVBVD version 0.4.1
Software version: VB
Scan 1/1, read all mdhs:   0%|                                                                   | 0.00/64.8M [00:00<?, ?B/s]Contents of file: sub-701_nuc-1H_loc-pcc_spec-lr-special.dat
The file contains these evalinfo flags with dimensions and sizes as follows:
image          :	Col, Cha, Set       	[4096   32   64]
Scan 1/1, read all mdhs:  98%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ | 63.7M/64.8M [00:00<00:00, 744MB/s]
spec2nii twix -e image sub-701_nuc-1H_loc-pcc_spec-lr-special.dat 

pymapVBVD version 0.4.1
Software version: VB
Scan 1/1, read all mdhs:   0%|                                                                   | 0.00/64.8M [00:00<?, ?B/s]Converting twix file sub-701_nuc-1H_loc-pcc_spec-lr-special.dat.
Looking for evalinfo flag image.
Traceback (most recent call last):
  File "/home/orco/.conda/envs/mrs/bin/spec2nii", line 10, in <module>
    sys.exit(main())
  File "/home/orco/.conda/envs/mrs/lib/python3.7/site-packages/spec2nii/spec2nii.py", line 401, in main
    spec2nii(*args)
  File "/home/orco/.conda/envs/mrs/lib/python3.7/site-packages/spec2nii/spec2nii.py", line 188, in __init__
    args.func(args)
  File "/home/orco/.conda/envs/mrs/lib/python3.7/site-packages/spec2nii/spec2nii.py", line 267, in twix
    args.verbose)
  File "/home/orco/.conda/envs/mrs/lib/python3.7/site-packages/spec2nii/twixfunctions.py", line 47, in process_twix
    if n_voxels > 1:
TypeError: '>' not supported between instances of 'str' and 'int'
Scan 1/1, read all mdhs:  98%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ | 63.7M/64.8M [00:00<00:00, 702MB/s]

If more informations are needed just tell me.

Dicom image to NiFTI

Hi @wtclarke,

I try to use the segmentation of fsl_mrs. Therefor I need to convert my T1 images to NiFTI files. If I try to use "spec2nii dicom /filepath/to/directory" I get an error message with the "ROWS"
File "/home/labor/.local/anaconda3/lib/python3.8/site-packages/spec2nii/dicomfunctions.py", line 27, in svs_or_CSI
rows = img.csa_header['tags']['Rows']['items'][0]
KeyError: 'Rows'

I also tried to use the twix T1-file that I exportet. I also get an error trying this.
/home/labor/sciebo/Bachelorarbeit/Porgramm/Desktop/20211118/20211118_Bedarf_Lennart/BEDARF_LENNART_20211118_JB02/JB_TMP_20211118_155400_190000/T1_MPRAGE_SAG_P2_ISO_1MM_0002

Do you have any suggestions what I can do? Maybe I don't need a NiFTI file for segmentation in fsl_mrs?

Thanks for your help.
Best reguards

spec2nii anon to also act on a JSON sidecar

Hi Will,

I'm tinkering with BIDS-ifying a pretty large dataset with BIDScoin. Currently, I need to run spec2nii anon and spec2nii extract separately after the conversion to remove PHI from the JSON sidecar. (Need to submit a separate issue in the BIDScoin repository because the anon option doesn't seem to get picked up correctly)

Would it be possible to allow the anon option to be passed at conversion time so that spec2nii generates de-identified nii and JSON files right away? dcm2niix allows something like this with the -ba argument (see https://www.nitrc.org/plugins/mwiki/index.php/dcm2nii:MainPage#General_Usage).

Thanks :)
Georg

Philips SOP Class UID error

I have faced the same problem. In addition, when I use the spec2nii philips_dcm function, I get the following error:
"Media Storage SOP Class UID {media_storage_class} not recognised as spectroscopy" Kindly Help

Originally posted by @karthikrrish in #40 (comment)

Spec2nii twix warning.

Investigate and fix <array_function internals>:200: RuntimeWarning: invalid value encountered in cast when calling spec2nii twix. The example data in fsl_mrs causes this.

Does auto conversion support TWIX data from XA50?

Dear William,

I ran the auto conversion 'spec2nii auto FILE' in Minicoda and received the following message.
The TWIX data was acquired using a XA50 machine. Any idea to solve this issue?

Best,

Steve


(my_env) C:\Users\SHUI>spec2nii auto C:\Users\SHUI\Desktop\Siemens_HERC\phantom_20240129\meas_MID00030_FID48369_smm_svs_herc_spdur_v1.dat
C:\Users\SHUI\AppData\Local\miniconda3\envs\my_env\lib\site-packages\spec2nii\spec2nii.py:409: UserWarning: Automatic conversion is an experimental feature. Please verify the output carefully.
warn('Automatic conversion is an experimental feature. Please verify the output carefully.')
Attempting conversion as Siemens Twix (.dat), evalinfo = 'image'
pymapVBVD version 0.5.6
Software version: VD
Traceback (most recent call last):
File "C:\Users\SHUI\AppData\Local\miniconda3\envs\my_env\Scripts\spec2nii-script.py", line 9, in
sys.exit(main())
File "C:\Users\SHUI\AppData\Local\miniconda3\envs\my_env\lib\site-packages\spec2nii\spec2nii.py", line 696, in main
spec2nii(*args)
File "C:\Users\SHUI\AppData\Local\miniconda3\envs\my_env\lib\site-packages\spec2nii\spec2nii.py", line 292, in init
args.func(args)
File "C:\Users\SHUI\AppData\Local\miniconda3\envs\my_env\lib\site-packages\spec2nii\spec2nii.py", line 421, in auto
self.twix(args)
File "C:\Users\SHUI\AppData\Local\miniconda3\envs\my_env\lib\site-packages\spec2nii\spec2nii.py", line 504, in twix
twixObj = twixObj[args.multiraid - 1]
AttributeError: 'Namespace' object has no attribute 'multiraid'

Bruker PRESS (ParaVision 3.5)

I have some MRS data from Bruker (ParaVision360 v 3.5), PRESS sequence. Both single coil and array.
Either way I'm getting this error:

spec2nii bruker 8/pdata/1/2dseq

Traceback (most recent call last):
File "/home/peter/fsl/lib/python3.11/site-packages/spec2nii/bruker.py", line 81, in yield_bruker
d.query(queries)
File "/home/peter/fsl/lib/python3.11/site-packages/brukerapi/dataset.py", line 713, in query
raise FilterEvalFalse
brukerapi.exceptions.FilterEvalFalse: FilterEvalFalse

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/peter/fsl/bin/spec2nii", line 10, in
sys.exit(main())
^^^^^^
File "/home/peter/fsl/lib/python3.11/site-packages/spec2nii/spec2nii.py", line 701, in main
spec2nii(*args)
File "/home/peter/fsl/lib/python3.11/site-packages/spec2nii/spec2nii.py", line 297, in init
args.func(args)
File "/home/peter/fsl/lib/python3.11/site-packages/spec2nii/spec2nii.py", line 670, in bruker
self.imageOut, self.fileoutNames = read_bruker(args)
^^^^^^^^^^^^^^^^^
File "/home/peter/fsl/lib/python3.11/site-packages/spec2nii/bruker.py", line 44, in read_bruker
for data, orientation, dwelltime, meta, name in yield_bruker(args):
File "/home/peter/fsl/lib/python3.11/site-packages/spec2nii/bruker.py", line 83, in yield_bruker
raise ValueError(f'Bruker dataset {d.path} is not suitable for conversion to mrs_nifti')
ValueError: Bruker dataset 8/pdata/1/2dseq is not suitable for conversion to mrs_nifti

I'm using spec2nii version 0.7.4 (can't figure how to update to current version...)

I'm happy to share the data if it helps.
Cheers,
Peter

No luck with Bruker data

Hello,

I have try to use spec2nii with Bruker data but it quickly run into trouble as it try to reshape some array:

I issue the command --> spec2nii bruker -m FID -o ./ ./10/fid while I reside into a directory which contains a subdirectory "./10". In ./10 is the "method" file and all the relevant fid, ... as they appear when a MRS experiment is run with Bruker. The output gives:

Traceback (most recent call last):
File "/Users/benagain/opt/anaconda3/bin/spec2nii", line 10, in
sys.exit(main())
File "/Users/benagain/opt/anaconda3/lib/python3.7/site-packages/spec2nii/spec2nii.py", line 485, in main
spec2nii(*args)
File "/Users/benagain/opt/anaconda3/lib/python3.7/site-packages/spec2nii/spec2nii.py", line 247, in init
args.func(args)
File "/Users/benagain/opt/anaconda3/lib/python3.7/site-packages/spec2nii/spec2nii.py", line 456, in bruker
self.imageOut, self.fileoutNames = read_bruker(args)
File "/Users/benagain/opt/anaconda3/lib/python3.7/site-packages/spec2nii/bruker.py", line 42, in read_bruker
for data, orientation, dwelltime, meta, name in yield_bruker(args):
File "/Users/benagain/opt/anaconda3/lib/python3.7/site-packages/spec2nii/bruker.py", line 71, in yield_bruker
d = Dataset(args.file, property_files=[bruker_properties_path], parameter_files=['method'])
File "/Users/benagain/opt/anaconda3/lib/python3.7/site-packages/brukerapi/dataset.py", line 180, in init
self.load()
File "/Users/benagain/opt/anaconda3/lib/python3.7/site-packages/brukerapi/dataset.py", line 254, in load
self.load_data()
File "/Users/benagain/opt/anaconda3/lib/python3.7/site-packages/brukerapi/dataset.py", line 502, in load_data
self._data = self._read_data()
File "/Users/benagain/opt/anaconda3/lib/python3.7/site-packages/brukerapi/dataset.py", line 512, in _read_data
return self._schema.deserialize(data, self._schema.layouts)
File "/Users/benagain/opt/anaconda3/lib/python3.7/site-packages/brukerapi/schemas.py", line 162, in deserialize
data = self._acquisitions_to_encode(data, layouts)
File "/Users/benagain/opt/anaconda3/lib/python3.7/site-packages/brukerapi/schemas.py", line 200, in _acquisitions_to_encode
return np.reshape(data, layouts['encoding_space'], order='F')
File "<array_function internals>", line 6, in reshape
File "/Users/benagain/opt/anaconda3/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 301, in reshape
return _wrapfunc(a, 'reshape', newshape, order=order)
File "/Users/benagain/opt/anaconda3/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 61, in _wrapfunc
return bound(*args, **kwds)
ValueError: cannot reshape array of size 8192 into shape (2048,1)

In the experiment the parameter PVM_SpecMatrix corresponds to a 1-dimensional array and is equal to 2048. I am not sure if this could be connected to the last line of the error message.

Thank you in advance for your comment,

Benoit

Python 3.7 end of life

I will be removing testing for, and claims of support for python 3.7 as it reached end of life status. Continued testing on 3.7 will encounter (and is already encountering) issues with dependency packages.

Change default behaviour of spec2nii philips

Default behaviour is to interpret multiple FIDs contained in SPAR/SDAT as DIM_COIL (probably as a default on the NIfTI-MRS class). Change the -t (--tag) option to have a default of DIM_DYN.

spec2nii does not support the ISMRMRD data

The ISMRM Raw Data Format (ISMRMRD) is a common raw data format, which attempts to capture the data fields that are required to describe the magnetic resonance experiment with enough detail to reconstruct images. The spec2nii now does not support the ISMRMRD data. How about to consider supporting the ISMRMRD data?

Issue to read DICOM MR Spectroscopy Storage (Philips and Siemens)

Hi,

Thank you for sharing your software.

I have DICOM data from different MRI scanners and for two scanners (one Philips and one Siemens) spec2nii does not work.
This is because the format is not the expected one. The tag (0008, 0016) SOP Class UID is "MR Spectroscopy Storage " as for the data from Siemens system with the software version XA (here for the Siemens scanner the software version is syngo MR E11).

The DICOM are quite similar as the one from XA software (for example the data are stored in the tag (5600, 0020) Spectroscopy Data ). However they are some differences for others tag in particular for the data from Philips system.

Maybe it can be usefull to check the storage method in order to chose wich part of the code use to read the rawdata and not only the software version ?
So far, here are the different SOP Class UID I found :

  • DICOM specifc for spectroscopy for both Siemens and Philips systems : '1.2.840.10008.5.1.4.1.1.4.2' (='MR Spectroscopy Storage')
  • classic DICOM for Philips systems : '1.3.46.670589.11.0.0.12.1'
  • classic DICOM for Siemens systems : '1.3.12.2.1107.5.9.1' (= 'CSA Non-Image')

I cannot share my data in open source but if you are interrested I can see if I can share them with you.

Kind regards,

Emmanuelle Gourieux

Siemens XA20 dat files not working with spec2nii

We have acquired some spectro-data (Press) with our Siemens VIDA using the "new" XA20 Software. I just wanted to point out the the conversion with spec2nii is not possible at the moment. I had the same problem with a Matlab-bases software (Osprey). So I guess it is a kind of basic data problem.
Here is my code + output:

spec2nii twix -v meas_MID00027_FID07653_svs_se_30_WS_on.dat
pymapVBVD version 0.4.3
Software version: VD
Contents of file: meas_MID00027_FID07653_svs_se_30_WS_on.dat
Multiraid file, 2 files found.
Selecting file 2. Use -m option to change.
The file contains these evalinfo flags with dimensions and sizes as follows:
image : Col, Cha, Ave, Phs [2080 42 80 2]

spec2nii twix -e image meas_MID00027_FID07653_svs_se_30_WS_on.dat
pymapVBVD version 0.4.3
Software version: VD
Converting twix file meas_MID00027_FID07653_svs_se_30_WS_on.dat.
Looking for evalinfo flag image.
Found data of size (2080, 42, 80, 2).
Traceback (most recent call last):
File "/usr/local/bin/spec2nii", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.9/site-packages/spec2nii/spec2nii.py", line 485, in main
spec2nii(*args)
File "/usr/local/lib/python3.9/site-packages/spec2nii/spec2nii.py", line 247, in init
args.func(args)
File "/usr/local/lib/python3.9/site-packages/spec2nii/spec2nii.py", line 320, in twix
self.imageOut, self.fileoutNames = process_twix(twixObj,
File "/usr/local/lib/python3.9/site-packages/spec2nii/twixfunctions.py", line 56, in process_twix
return process_svs(twixObj, base_name_out, name_in, dataKey, dim_overides, quiet=quiet, verbose=verbose)
File "/usr/local/lib/python3.9/site-packages/spec2nii/twixfunctions.py", line 112, in process_svs
meta_obj = extractTwixMetadata(twixObj['hdr'], basename(twixObj[dataKey].filename))
File "/usr/local/lib/python3.9/site-packages/spec2nii/twixfunctions.py", line 329, in extractTwixMetadata
obj = nifti_mrs.hdr_ext(mapVBVDHdr['Meas'][('Frequency')] / 1E6,
KeyError: 'Frequency'

Best,
Karl

Some files are perhaps unintentionally not distributed

  • CHANGELOG.md should probably be in the PyPI sdist
  • spec2nii/GE/VESPA_LICENSE should definitely be in the PyPI sdist and the wheels, since it is referenced in the main LICENSE file
  • either the tests should be omitted from the PyPI sdist, or all the necessary files should be included: currently, tests/__init__.py, tests/io_for_tests.py, and tests/pytest.ini are missing from the PyPI sdist

SVS not recognize - DICOM Philips

Hi,

I got trouble reading classic DICOM from Philips system with specnii (I used the command philips_dcm DCM_FILE_or_DIR with DCM_FILE_or_DIR = a directory with all the DICOM files).
We acquired SVS sequences but with several repetitions and in the function svs_or_CSI used for Philips DICOM the output from img.image_shape is (1, 256) and so it returns 'CSI' and not 'SVS'.

Am I missing something ?

Best,

Emmanuelle

converting RDA results in UnicodeDecodeError

When I try to convert a Siemens RDA-File I get the following Error:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6 in position 27: invalid start byte

The Error is raised by:
spec2nii/Siemens/rda.py", line 47, in convert_rda

Philips 3T dicom, incorrect orientation reported

Reported on FSL JISC list by Alex Ensworth

The other issue I am having has to do with voxel placement. The voxel placement I get after using svs_segment and I fit the spectrum (using fsl_mrs with the --t1 and --tissue_frac data from svs_segment) is incorrect (see the attached image labelled fsl_mrs_voxel_location). I have also attached an image of the correct voxel placement which is in the PCC (labelled correct_voxel_location). Any suggestions you can provide on how I might go about correcting the location is greatly appreciated!

However, I am still stuck on the voxel placement issues (I guess I was hoping that using dcm2niix would have fixed it).
To answer your questions, I am using .SPAR/.SDAT data for MRS and my structural images are classic DICOM files. I was converting them using mricron and using that interface or MRIcroGL to display them. After seeing your suggestion, I tried using dcm2niix to convert and then fsleyes to display them. The screenshots with the voxel on them that I have included are the ones produced by the "--report" flag when doing fsl_mrs. I don't do much displaying otherwise - are there certain steps in the pipeline that I could display and thus check for voxel placement or orientation errors?
I will also add that I previously did this step using locally written Matlab code, and had issues with placing the voxel in the right location there too. I had to permute the image to have it oriented correctly.

Again, I have attached a few images that describe my findings: the desired orientation (titled correct_voxel_location.png), the placement of the voxel using mricron for data conversion and the display is from the fsl_mrs --report output (mricron_fsl_mrs.png) and also the placement of the voxel using dcm2niix for data conversion and again the display from fsl_mrs (dcm2niix_fsl_mrs.png). The mricron and dcm2niix data conversion methods appear to be identical.

spec2nii ge Pfile: spec2nii.GE.ge_read_pfile.UnknownPfile: No Pfile mapper for pulse sequence = slaser

Hi Will,
I couldn't find this error elsewhere, so I hope this is the right place.
I am trying to analyze some GE semi LASER data, but I get an error right away trying to convert the Pfile to Nifti

spec2nii ge P39424.7

Gives me this error:

Traceback (most recent call last): File "/home/weberam2/miniconda3/bin/spec2nii", line 8, in <module> sys.exit(main()) File "/home/weberam2/miniconda3/lib/python3.8/site-packages/spec2nii/spec2nii.py", line 521, in main spec2nii(*args) File "/home/weberam2/miniconda3/lib/python3.8/site-packages/spec2nii/spec2nii.py", line 272, in __init__ args.func(args) File "/home/weberam2/miniconda3/lib/python3.8/site-packages/spec2nii/spec2nii.py", line 473, in ge self.imageOut, self.fileoutNames = read_pfile(args.file, args.fileout) File "/home/weberam2/miniconda3/lib/python3.8/site-packages/spec2nii/GE/ge_pfile.py", line 66, in read_pfile pfile = Pfile(filename) File "/home/weberam2/miniconda3/lib/python3.8/site-packages/spec2nii/GE/ge_read_pfile.py", line 133, in __init__ self.map_data() File "/home/weberam2/miniconda3/lib/python3.8/site-packages/spec2nii/GE/ge_read_pfile.py", line 275, in map_data mapper = self.get_mapper File "/home/weberam2/miniconda3/lib/python3.8/site-packages/spec2nii/GE/ge_read_pfile.py", line 209, in get_mapper raise UnknownPfile("No Pfile mapper for pulse sequence = %s" % psd) spec2nii.GE.ge_read_pfile.UnknownPfile: No Pfile mapper for pulse sequence = slaser

I'm happy to send you the Pfile if that helps

Cheers,

Alex W.

Issue with a special sequence from Jamie Near @XA30

Hi Will,
I have difficulties to properly convert & processed the data from Jamie Near's SPECIAL. My Prisma has XA30 Numaris. I've already emailed @jamienear about the same problem in FID-A. I have enabled "in line reference" for those scans, so my TWIX file has 2 frames. The spectra look perfect on the console and also when I work with RDA files. I can provide You the original TWIX file in the private message, if that's ok.
special_twix
TWIX
special_rda
RDA
Kind regards,
Bartosz Kossowski

SPEC2NII Returns 0 Units

Hi all,

I thought that I had successfully converted DICOM to NIFTI for my MRS data. However, when I looked at the xyzt units in the NIFTI header, it showed that there were 0 units. Is there an issue with conversion for certain types of DICOM?

Thanks.

Converrsion fails using Siemens dicom file

Hello, I'm facing an error while converting dicom files from Siemens scanner (Prisma_fit, VE11). It seems that the command expecting a software version indicated in the dicom header and it's missing. The error is pointing to "dicomfunctions.py", line 59, in xa_or_vx
f' {img.dcm_data.SoftwareVersions} baseline scanner.'
File "..../lib/python3.9/site-packages/pydicom/dataset.py", line 908, in getattr
return object.getattribute(self, name)
AttributeError: 'FileDataset' object has no attribute 'SoftwareVersions'

Thanks in advance for any recommendations!
Best,
Behrouz

An option to produce BIDS sidecar .json files to accompany .nii{.gz}

@wtclarke , thanks for chiming in on nipy/heudiconv#381 (comment)! I've decided to proceed with specific question here since pertains more to spec2nii than to heudiconv ;)

Are you familiar with BIDS?
I wonder if similarly to -b option of dcm2niix by @neurolabusc for DICOM to NIfTI conversion, spec2cli could also produce a side car .json files filling up "interesting" fields as being harmonized in the BIDS Enhancement proposal for MRS: BEP022?

Problem converting Siemens rda

Hi,

I'm new to MRS data and am trying to convert some rda files but am running into an error. Here is the traceback:

Traceback (most recent call last):
  File "/home/mdefende/.conda/envs/fslmrs/bin/spec2nii", line 10, in <module>
    sys.exit(main())
  File "/home/mdefende/.conda/envs/fslmrs/lib/python3.10/site-packages/spec2nii/spec2nii.py", line 521, in main
    spec2nii(*args)
  File "/home/mdefende/.conda/envs/fslmrs/lib/python3.10/site-packages/spec2nii/spec2nii.py", line 272, in __init__
    args.func(args)
  File "/home/mdefende/.conda/envs/fslmrs/lib/python3.10/site-packages/spec2nii/spec2nii.py", line 388, in rda
    self.imageOut, self.fileoutNames = convert_rda(args.file, args.fileout, args.verbose)
  File "/home/mdefende/.conda/envs/fslmrs/lib/python3.10/site-packages/spec2nii/rda.py", line 36, in convert_rda
    if len(match.groups()) < 2:
AttributeError: 'NoneType' object has no attribute 'groups'

The PI says it's a standard MRS sequence and isn't sure why there would be an issue with it compared with others. I was just hoping for some advice on this. Thanks

Inconsistent voxel position in converted rda and twix files of a same acquisition

Hello @wtclarke,

I encountered an unusual issue. I'm trying to read voxel positions to generate a mask for custom shimming. Previously, I achieved this by converting twix data to NIfTI format and extracting the qoffset values, which matched those visible on the scanner. I've written code to accomplish this, but encountered a problem: I couldn't use a twix file as a test file on Github to verify functionality (due to its large size). Consequently, I opted to use an RDA file instead.

However, I found out that the qoffset values from the same acquisition, after being read from the converted NIfTI files, differ between twix and RDA files. Below, you can see the header info for both files.

Twix-converted NIfTI header:
qoffset_x : -0.293681652341
qoffset_y : 62.7648077675
qoffset_z : 15.6147164181
srow_x : [20. -0. -0. -0.29368165]
srow_y : [ -0. -19.99910558 -0.18914551 62.76480777]
srow_z : [ 0. 0.18914551 -19.99910558 15.61471642]

RDA-converted NIfTI header:
qoffset_x : -10.293679
qoffset_y : 72.764361
qoffset_z : 15.520146
srow_x : [ 20. -0. -0. -10.293679]
srow_y : [ -0. -19.99910563 -0.18914005 72.764361 ]
srow_z : [ 0. 0.18914005 -19.99910563 15.520146 ]

the same sidecar files for three different MRS files

Hi,
I used the spec2nii command to generate sidecar files for Siemens dicom MRS data. I three types single-voxel MRS files: _ref (water reference file), _ECC (eddy current corrected), and _noECC - for ACC and Hip.

The resulting sidecar files are identical for the three filetypes, I can distingush only based on the brain region of the svs (see below), but no way to distinguish between ref, ECC, and noECC.

{
  "SequenceName": "*svs_se",
  "ProtocolName": "ACC_svs"
}

I was hoping to use the sidecar files to sort the fies into BIDS format (improvised since BIDS doesn't define MRS, but still). Do you know if there's a way I can do that?

Issue with Minnesota s-LASER TE & water references

Hi Will

We've acquired some data using the latest Siemens s-LASER sequence from Dinesh Deelchand at Minnesota and I encountered two issues when using spec2nii to convert the data:

  1. The TE is not correctly recognized in the NIfTI (TWIX and DCM). Looking at the TWIX header, it seems the sub-echo times are stored separately (they're specified separately in the exam card) and spec2nii grabs the first sub-echo time, rather than the full TE.
  2. Relatively minor but thought I'd flag it, spec2nii doesn't identify when users acquire the water reference as a part of their protocol. In our case, we acquired 4 unsuppressed averages-two stored before the water-suppressed transients and two afterward.

I have a workaround for both of these in our data, so no urgency, and I'm happy to share the de-identified data if it would be useful to you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.