The function writes a SimpleITK image object to MetaImage file. writeMHD ( img, filePath, singleFile = True, overwrite = True, useCompression = False, compressionLevel = 5, displayInfo = False ) Object or tuple of objects of a SimpleITK image. Parameters :įileNames ( string or array_like) – A path or an iterable (list, tuple, etc.) of paths to MetaImage file.ĭisplayInfo ( bool, optional) – Displays a summary of the function results. The function reads a single MetaImage file or an iterable of MetaImage filesĪnd creates an instance or tuple of instances of a SimpleITK object. Read MetaImage image to SimpleITK image object. readMHD ( fileNames, displayInfo = False ) MetaImage files (*.mhd, *.mha) fredtools. an obsolate format used by the FRED Monte Carlo engine for saving 3D images (not recommended),ĭicom format (reading only) for 3D/2D images (e.g. MetaImage format in double (*.mhd+*.raw) or single files (only *.mhd), : v1.0.0: Separated image class into its own medimage module.A collection of useful functions for reading and writing images are implemented.Added CT rescaling when openingen Dicom image. : v1.0.4: New and much faster gamma computation (order of 5 minutes).: v1.0.6: Bugfix, dicom write still incomplete.# note: array is sorted in reverse for DVHs, i.e. Print('No mask or maskregion specified using whole volume for DVH analysis.') Maskim.tomask_atthreshold((opt.maskregion/100.)*maskim.max()) Print('Using isodose contour at',opt.maskregion,'percent of maximum dose as region for DVH analysis.') Maskim = image.image(path.abspath(opt.maskimage)) Print('Using',opt.maskimage,'as region for DVH analysis.') If opt.maskregion = None and path.isfile(path.abspath(opt.maskimage)): Im = image.image(path.abspath(opt.inputimage)) Parser.add_argument('-maskregion',default=None,type=float) Parser.add_argument('-maskimage',default=None) Parser = argparse.ArgumentParser(description='Supply an image and a mask or percentage for isodose contour in which to compute the DVH.') A lot of machine learning tooling are heavy users of numpy, and therefore getting your images in is straightforward with this package. It is now a core component to my analyses, and perhaps it can be useful to you too. The idea is that you can take the medimage directory, drop it into any project, and be able to work with medical images as numpy arrays. This image class grew to suit my needs as part of my phd_tools and later postdoc_tools repos, and in a new job I ported it to Python 3 and added filesupport for AVSFields and Dicom images. Fortunately, the (uncompressed) MetaImage disk format was so straightforward even I could understand it, and it was even suprisingly performant. I wanted to have a thin and pure Python wrapper around numpy that would allows me to read in and write out image data. ITK's Python bindings (SimpleITK) was not pippable or easily usable yet, and I found working with image data as numpy arrays far preferable and faster than using ITK as a library in custom C++ programs which I'd need to compile and recompile as an analysis developed. This project started out at a time when I was analyzing lots of Gate image outputs. SimpleITK write also only seems to produce usable dicoms files when updating an existing image, not when creating a new one from scratch. If it would, it would require SimpleITK, primarily because pydicom does not support dicom image write. This component is governed by its own license.ĭicom write is not supported right now. For NKI decompression I supply a 64bit Linux and Windows lib, if you need support for other platforms you can compile the function in medimage/nki_decomp yourself. Of particular interest perhaps are the DVH analysis function, and the distance to agreement calculation. Included are some basic mathematical operations, some masking functions and crop and resampling functions. Slicing, projections, mathematical operations, masking, stuff like that is very easy with numpy, so you can easily extend things to what you need. imdata member) such that you can easily work with images in these data formats. The image class is a thin wrapper around typed numpy array objects (the. XDR reading includes NKI compressed images (useful to work with your Elekta images). This library supports r/w MetaImage (MHD,ITK), r/w AVSField (.xdr) and read Dicom images.
0 Comments
Leave a Reply. |