Giter Club home page Giter Club logo

nii2dcm's People

Contributors

tomaroberts 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  avatar  avatar  avatar  avatar  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  avatar  avatar

nii2dcm's Issues

Improve dcm.py inheritance

Related to #8 โ€“ need to improve class inheritance. Currently, the Dicom class is too MR biased.

TODO:

  • shift the add_module() calls to DicomMRI subclass
  • need to ensure init_study_tags() and init_series_tags() are called after all the other tags in DicomMRI subclass are initialised
  • replicate this structure with DicomCT subclass that calls modules relevant to NEMA CT Image Module Table

git exception after pip install

I get this exception when run nii2dcm under windows after pip install:

nTraceback (most recent call last):
  File "D:\tools\WPy64-39100\python-3.9.10.amd64\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "D:\tools\WPy64-39100\python-3.9.10.amd64\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "D:\tools\WPy64-39100\python-3.9.10.amd64\Scripts\nii2dcm.exe\__main__.py", line 4, in <module>
  File "D:\tools\WPy64-39100\python-3.9.10.amd64\lib\site-packages\nii2dcm\__main__.py", line 9, in <module>
    from nii2dcm._version import __version__
  File "D:\tools\WPy64-39100\python-3.9.10.amd64\lib\site-packages\nii2dcm\_version.py", line 2, in <module>
    __version__ = Version.from_git().serialize(metadata=False, style=Style.SemVer)
  File "D:\tools\WPy64-39100\python-3.9.10.amd64\lib\site-packages\dunamai\__init__.py", line 1058, in from_git
    _detect_vcs(vcs)
  File "D:\tools\WPy64-39100\python-3.9.10.amd64\lib\site-packages\dunamai\__init__.py", line 355, in _detect_vcs
    raise RuntimeError(
RuntimeError: This does not appear to be a Git project

seems the version is detect from current git directory and get a git exception?

AttributeError using reference dicom

Thanks @tomaroberts for your great package - using the cli if I add a reference image i get:

"/dcm_writer.py", line 89, in transfer_ref_dicom_series_tags for current_attribute in dcm.attributes_to_transfer:
AttributeError: 'Dicom' object has no attribute 'attributes_to_transfer'

Orientation of DICOM fies

I, i have to process a directory of nifti files for a conectome analisis and i succesfully converted the files into dicom, as the software only works on a directory of dicom files. Now the software doesnt process the input folder as the images are in ALS orientation. This can be fix on -dicom type modality or is an aditional step to implement?. ITK-SNAP recognize the imagen as dicom series but does not tell much about orientation.

Issues with translation of images

First off - great tool!

I am having trouble with the tool, in ITK-snap and the imported DICOM the centres in the axial plane are way off (see below)

image

I am looking at the dataset:
https://openneuro.org/datasets/ds003949/versions/1.0.1

specifically in that example sub-336, I can't seem to find the error. I assume it's something to do with the way that the slice positions are calculated.

Any help would be great!

dicom_type for CT?

Hello!
when I run nii2dcm input.nii.gz output -d CT, I got :
error

code

dicom_type only for MR and SVR?

Ensure output files end in .dcm

Currently output files do not have an extension, they are just output as:

IM_0001
IM_0002
...
IM_XXXX

AIDE requires files to have .dcm extension, so will implement this by default, e.g.:

IM_0001.dcm
IM_0002.dcm
...
IM_XXXX.dcm

dunamai RuntimeError and UnboundLocalError: local variable 'nZ' referenced before assignment

Thanks for your work on nii2dcm! I'm considering integrating this as part of my QSM processing toolbox, QSMxT.

However, I'm having problems using it in my miniconda setup:

(qsmxt) ~/.../data/qsmtest/qsm: nii2dcm sub-1_ses-20231020_part-phase_T2Starw_romeo-unwrapped_normalized_pdf_rts_twopass_ref.nii dicom-output-directory/ --dicom-type MR
Traceback (most recent call last):
  File "/home/ashley/neurodesktop-storage/miniconda3/envs/qsmxt/bin/nii2dcm", line 5, in <module>
    from nii2dcm.__main__ import cli
  File "/home/ashley/neurodesktop-storage/miniconda3/envs/qsmxt/lib/python3.8/site-packages/nii2dcm/__main__.py", line 9, in <module>
    from nii2dcm._version import __version__
  File "/home/ashley/neurodesktop-storage/miniconda3/envs/qsmxt/lib/python3.8/site-packages/nii2dcm/_version.py", line 2, in <module>
    __version__ = Version.from_git().serialize(metadata=False, style=Style.SemVer)
  File "/home/ashley/neurodesktop-storage/miniconda3/envs/qsmxt/lib/python3.8/site-packages/dunamai/__init__.py", line 1058, in from_git
    _detect_vcs(vcs)
  File "/home/ashley/neurodesktop-storage/miniconda3/envs/qsmxt/lib/python3.8/site-packages/dunamai/__init__.py", line 355, in _detect_vcs
    raise RuntimeError(
RuntimeError: This does not appear to be a Git project

It is related somehow to the dunamai package. Any idea what could be causing this?

I tried initialising a git repository in the local directory to see if that could be a workaround, but then I have a new problem:

(qsmxt) ~/.../data/qsmtest/qsm: nii2dcm -d MR sub-1_ses-20231020_part-phase_T2Starw_romeo-unwrapped_normalized_pdf_rts_twopass_ref.nii dicom-output-directory/
Traceback (most recent call last):
  File "/home/ashley/neurodesktop-storage/miniconda3/envs/qsmxt/bin/nii2dcm", line 8, in <module>
    sys.exit(cli())
  File "/home/ashley/neurodesktop-storage/miniconda3/envs/qsmxt/lib/python3.8/site-packages/nii2dcm/__main__.py", line 55, in cli
    run_nii2dcm(
  File "/home/ashley/neurodesktop-storage/miniconda3/envs/qsmxt/lib/python3.8/site-packages/nii2dcm/run.py", line 38, in run_nii2dcm
    nii2dcm_parameters = nii2dcm.nii.Nifti.get_nii2dcm_parameters(nii)
  File "/home/ashley/neurodesktop-storage/miniconda3/envs/qsmxt/lib/python3.8/site-packages/nii2dcm/nii.py", line 38, in get_nii2dcm_parameters
    nInstances = nZ*nF
UnboundLocalError: local variable 'nZ' referenced before assignment

Looking at your code in nii.py, I can see that this is happening because of the dimensions of my file:

>>> nii.header['dim']
array([  3, 164, 205, 205,   0,   0,   0,   0], dtype=int16)

Which will not be handled correctly by the initialization code:

https://github.com/tomaroberts/nii2dcm/blob/09d20e02f61da2aa5e7a2e57bd420828021f0d92/nii2dcm/nii.py#L29C1-L35C58

My file is a 3D volume with 205 slices, each with dimensions 164x205. It is a quantitative susceptibility map with floating-point values in the range of about -4 to +3, with most values around zero.

Create GitHub Action to test running of nii2dcm

  • create build_and_test_cli.yml

  • Build tests and upload test data for the following:

    • Dicom class
    • DicomMRI class
    • DicomMRISVR class
  • Need to make DicomCT class, etc. and make tests. Can pull public MRI/CT data.

Outputs not in .dcm?

Hello,

I am trying to convert .nii files into dicoms file and i ran the code using

nii2dcm {path_to_.nii} {output_dir} 

But the output files in the output_dir are not in .dcm format/with no .dcm extensions

eg.
image

Add in Logger

Need to update nii2dcm with proper logging.

  • Currently just some placeholder print() statements.
  • Implement log levels

Add checks to ensure robustness DICOM Attributes defined in multiple Modules

Realised that some DICOM Attributes are defined in more than one Module, e.g.:

  • BitsAllocated is defined in both Image Pixel Module and MR Image Module

Current behaviour means that which ever Module is called second overrides. Not ideal.

TODO:

  • when calling Module subclasses, check if Attributes already exist in the Dicom object and then perform relevant logic, e.g. overwrite and warn.

Improve image contrast windowing in DICOM output

Currently, when generating different types of DICOM (MRI, CT, different scanners, etc.) the intensity values/windowing in the output DICOM can be incorrect, e.g.:

Output DICOM contrast from input CT NIfTI dataset:

image

Some modalities are working, others are not.

TODO:

  • improve the method of interpreting the NIfTI voxel values and correctly setting the contrast/windowing/slope tags in the DICOM files.

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.