![]() ![]() You can call EraseMetaData to remove the extraneous/redundant tags. With ITK, when an image if filtered the meta-data tags are not propagated, the this issue is not frequently encountered. I’m guessing that the itk::NifTiImageIO reader is trying to do something “smart” with the NifTi tags to preserve them. (sform_code_name) = "NIFTI_XFORM_UNKNOWN" ![]() I did a test with NifTi and there were quite a lot of NifTi tags: In : import SimpleITK as sitk When you first read an image in ITK, the Image may contain additional meta data tags from the reader. The supported image file formats should include at least the following. ![]() Print('\nGetImageFromArray, written with ITK') MedPy relies on SimpleITK, which enables the power of ITK for image loading and saving. Nib.Nifti1Image(array, affine).to_filename(filepath_nib) With gzip.open(image_path, 'rb') as f_in: With NamedTemporaryFile(suffix='.nii') as f: Here’s some code to show what I mean, and the output: import gzip If I read and write and image with SimpleITK, the header is incorrect. datadirectory directory seriesIDs (datadirectory) if not seriesIDs: print ('ERROR: given directory '' datadirectory '' does not contain a DICOM series.') sys. When I create an image using GetImageFromArray, the written header is fine. First obtain the series file names using the image series reader. qfac is the first value of the pixdim array in the header and is expected to be -1 or 1. NIfTI docs say that it “should not occur” that qfac is 0. #include "itkImage.h" #include "itkGDCMImageIO.h" #include "itkGDCMSeriesFileNames.h" #include "itkImageSeriesReader.h" #include "itkImageFileWriter.I’m using SimpleITK 1.2.4 to read and write NIfTI images. GetOutput ()) print ( "Writing: " outFileName ) writer. join ( dirName, seriesIdentifier ".nrrd" ) if args. MetaImage: MReadElementsROI: data not read completely - ITK ITK MetaImage: MReadElementsROI: data not read completely JKKim (JK Kim) July 14, 2021, 8:54pm 1 Hi I am using SimpleITK 2.0.2 and Python 3.7.9 to read a 3D CT image in the compressed mhd format (ct.mhd, ct.zraw). ForceOrthogonalDirectionOff () writer = itk. GetFileNames ( seriesIdentifier ) reader = itk. series_name seriesFound = True print ( "Reading: " seriesIdentifier ) fileNames = namesGenerator. exit ( 1 ) print ( "The directory: " dirName ) print ( "Contains the following DICOM Series: " ) for uid in seriesUID : print ( uid ) seriesFound = False for uid in seriesUID : seriesIdentifier = uid if args. ![]() GetSeriesUIDs () if len ( seriesUID ) < 1 : print ( "No DICOMs in: " dirName ) sys. SetDirectory ( dirName ) seriesUID = namesGenerator. SetGlobalWarningDisplay ( False ) namesGenerator. AddSeriesRestriction ( "0008|0021" ) namesGenerator. SetUseSeriesDetails ( True ) namesGenerator. These nine images represent just some of the capability of VTK. When using the default settings for the ImageFileReader class or the ReadImage function you have minimal control over the reading. This example illustrates how to explicitly select a specific IO for image reading. ctype ( "signed short" ) Dimension = 3 ImageType = itk. This class tries to find an appropriate reader. IO Selection for Image Reading¶ Overview¶. parse_args () # current directory by default dirName = "." if args. add_argument ( "series_name", nargs = "?" ) args = parser. add_argument ( "output_image", nargs = "?" ) parser. add_argument ( "dicom_directory", nargs = "?", help = "If DicomDirectory is not specified, current directory is used", ) parser. ArgumentParser ( description = "Read DICOM Series And Write 3D Image." ) parser. GitHub - ptyap/MATLAB-ITK-IO: MATLAB MEX files for reading/writing ITK supported image files (NIfTI, Analyze, NRRD, and MetaImage). #!/usr/bin/env python import sys import os import itk import argparse parser = argparse. MATLAB MEX files for reading/writing ITK supported image files (NIfTI, Analyze, NRRD, and MetaImage). ![]()
0 Comments
Leave a Reply. |