Python - vtkDICOMImageReader array input? - python

I'm building a system for viewing DICOM files. DICOM files located in the specified folder are read with dcmread and put in a list. I check the metadata to separate the series by the series number in the information, then I create a dictionary with several lists, one for each series, which contain the respective scans. In the program, therefore, I can select which series to display with the 3D reconstruction. I noticed however that with vtkDICOMImageReader I can only specify a file or a directory. Can I also select a list containing DICOM files in some way?

vtkDICOMImageReader derives from vtkImageReader2, you can use the vtkImageReader2::SetFileNames(vtkStringArray *)
https://vtk.org/doc/nightly/html/classvtkImageReader2.html#ac084edcfab5d27247a7683892a95617e
By design vtkImageReader2 needs to read the files from disk (think UpdateExtent != WholeExtent).
If you are looking to import a c-array as an image into VTK, you should instead start using:
https://vtk.org/doc/nightly/html/classvtkImageImport.html

Related

Kedro: How to pass multiple same data from a directory as a node input?

I have a directory with multiple files for the same data format (1 file per day). It's like one data split into multiple files.
Is it possible to pass all the files to A Kedro node without specifying each file? So they all get processed sequentially or in parallel based on the runner?
If the number of files is small and fixed, you may consider creating those preprocessing pipeline for each of them manually.
If the number of files is large/dynamic, you may create your pipeline definition programmatically for each of them, adding them all together afterwards. Same would probably apply to programmatic creation of the required datasets.
Alternative option would be to read all the files once in the first node, concatenate them all together into one dataset, and make all consecutive preproc nodes use that dataset (or its derivatives) as inputs

how to have indexed files in storage in python

I have a huge dataset of images and I am processing them one by one.
All the images are stored in a folder.
My Approach:
What I have tried is that I have tried reading all the filenames in memory and whenever a call for a certain index is sent, I load the corresponding image.
The problem is that it is even not possible to keep the paths and the names of the files in memory due to the huge dataset.
Is it possible to have an indexed file on storage and one is able to read a file name at a certain index.
Thanks a lot.

HDF5 and Python: Automatic export of an object

I'm new to the HDF5 file format and have been experimenting successfully in Python with h5py. Now its time to store real data.
I will need to store a list of objects, where each object can be one of several types and each type will have a number of arrays and strings. The critical part is that the list of objects will be different for each file, and there will be hundreds of files.
Is there a way to automatically export an arbitrary, nested object into (and back from) an HDF5 file? I'm imagining a routine that would automatically span the hierarchy of a nested object and build the same hierarchy in the HDF5 file.
I've read through the H5PY doc and don't see any spanning routines. Furthermore, google and SO searches are (strangely) not showing this capability. Am i missing something or is there another way to look at this.

Can I attach metadata to NumPy arrays?

I am writing a pipeline-style image processing program. I would like to log all intermediate steps it takes.
Currently, it loads all images from a directory and stores them all as NumPy arrays (for further processing with OpenCV). I would like to attach a string tag to each array to see the name of the original file it came from, so I don't have to drag that name everywhere. Is there a simple way to do that?

Python To Read Images from Multiple Folders and Create a Large One

I am new to Python. I need process such a task. I have multiple test images for each unit, distributed in different subfolders.
For instance, I have multiple images
/folder/subfolder1/../i1.png
/folder/subfolder2/../i2.png
/folder/subfolder3/../i3.png
....
....
/folder/subfolder100/../i100.png
I can read all image files and create a list object. The next step is to render all of them in a matrix format 10x10, each each matrix element the particular ix.png. Prefer that below there is the caption of its own name ix.
How can I do that?

Categories

Resources