tomaroberts / nii2dcm Goto Github PK
View Code? Open in Web Editor NEWnii2dcm: NIfTI to DICOM creation with Python
License: Other
nii2dcm: NIfTI to DICOM creation with Python
License: Other
create build_and_test_cli.yml
Build tests and upload test data for the following:
Need to make DicomCT class, etc. and make tests. Can pull public MRI/CT data.
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.
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
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'
Related to #8 โ need to improve class inheritance. Currently, the Dicom class is too MR biased.
TODO:
add_module()
calls to DicomMRI subclassinit_study_tags()
and init_series_tags()
are called after all the other tags in DicomMRI subclass are initialisedIt would be very useful to have an enhanced DICOM output option.
Push to TestPyPI on pull-request?:
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)
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!
Hello,
the minimum maximum values of the niftis I have are between 735 and 3095. However, when I use your code and convert it to niftiye, it comes as minimum 0 maximum 4095. This causes the current image to be distorted, causing excessive black places to appear white. I did not see an adjustment that I can change this setting. I think I missed the relevant lines in the code.
I would be glad if you can help with this issue. Thanks for the work.
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?
-r / --ref_dicom
option which points at a DICOM file and transfers attributes to nii2dcm generated DICOMnii2dcm F:\Datasets\nii\AF_cta\Site2\CT\1052519\untitled_original.nii.gz F:\Code\DeepLearning\GAN\CTA-GAN\data\Site2\CT\1052519/
please help me !
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:
Some modalities are working, others are not.
TODO:
Currently manually push to PyPI. Implement GHA to push to PyPI on release:
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:
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.
Need to update nii2dcm with proper logging.
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 ModuleCurrent behaviour means that which ever Module is called second overrides. Not ideal.
TODO:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.