Closed ryancinsight closed 4 years ago
It doesn't appear that the dicom_read
function is meant to be a robust dicom reader and deal with all the associated nuances and possibilities. You're probably much better off using something like [dcm2nii] or implementing your own reader.
Well I'm trying to avoid the reading and writing to disk as it seems something happens to my pixel data randomly. currently I'm doing this with simpleitk. def read_images(direc, filename=None): series_IDs = sitk.ImageSeriesReader.GetGDCMSeriesIDs(direc) series_file_names = sitk.ImageSeriesReader.GetGDCMSeriesFileNames(direc, series_IDs[0]) series_reader = sitk.ImageSeriesReader() series_reader.SetNumberOfThreads(mp.cpu_count()) series_reader.SetFileNames(series_file_names) series_reader.MetaDataDictionaryArrayUpdateOn() series_reader.LoadPrivateTagsOn() image=series_reader.Execute() sitk.WriteImage(image, filename, True) return ants.image_read(filename,dimension=3,pixeltype='float', reorient='RAS')
I've been trying to find it but is their a script for itk (if i convert to the python itk instead of simpleitk) to antsimage in python like I'm seeing in the pybind11 examples?
What about going through numpy as an intermediary?
That would be fine, I believe I saw something similar image read which seems to be doing great for nifti images. I was trying to modify something similar to that but using the itk image series reader with pybind 11 but got stuck when it came to the ITK GDCM wrapping, which is probably do to my lack of understanding of pybind11 and c.
`#include <pybind11/pybind11.h> // header for wrapping code
namespace py = pybind11; // needed to use "py:"
template
typename NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New() ;
nameGenerator->SetUseSeriesDetails(True);
nameGenerator->AddSeriesRestriction("0008|0021");
nameGenerator->SetGlobalWarningDisplay(False);
nameGenerator->SetDirectory(Directory.c_str() );
using SeriesIdContainer = std::vector< std::string >;
const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();
auto seriesItr = seriesUID.begin();
auto seriesEnd = seriesUID.end();
seriesItr = seriesUID.begin();
seriesIdentifier = seriesItr->c_str();
seriesItr++;
using FileNamesContainer = std::vector< std::string >;
return FileNamesContainer fileNames =nameGenerator->GetFileNames(seriesIdentifier);
}
template
template
typename ImageReaderType::Pointer image_reader = ImageReaderType::New() ;
image_reader->SetImageIO(dicomIO<ImageIOType>);
image_reader->SetFilesName( GDCMHelper<NameGeneratorType>(Directory)) ;
image_reader->Update();
ImagePointerType itkImage = image_reader->GetOutput();
return wrap<ImageType>( itkImage );
}
template
what was the problem with this approach? looks like you have most of the code needed. did you follow this:
https://github.com/ANTsX/ANTsPy/blob/master/CONTRIBUTING.md
it would most certainly be useful to have this fleshed out.
stale.
Hello I’ve tried the dicom read function but I don’t want the origin of my images to be the first slice.
Is there any way to implement the imageseriesreader with gdcm series I’d and filenames that itk has for dicom read?