# MedicalImageConverter
*MedicalImageConverter* is a Python package for working with medical image files. It
lets the user read in images or ROIs (regions of interest), and converts them to 3D
numpy arrays. It also allows the user to input non-organized datasets (multiple images
inside a single folder). Currently, this module only works for Dicom data with the hopes of expanding to
other data formats in the future.
The module currently imports 9 different modalites and RTSTRUCT files. The accepted
modalites are:
1. CT
2. MR
3. US
4. PT
5. MG
6. DX
7. NM
8. XA
9. CR
The CT and MR modalities have been tested extensively, along with their respective
ROIs. The other 7 modalities have been tested but only on a few datasets a piece.
For RTSTRUCTS, only those referencing CT and MR have been tested.
The images will be converted to Head-First-Supine (if not so already), and the
image position will be updated to reflect the needed rotations.
Disclaimer: All the files will be loaded into memory so be sure you have enough
RAM available. Meaning don't select a folder path that contains 10s of different
patient folders because you could possibly run out of RAM. Also, this module does
not distinguish between patient IDs or patient names.
## Installation
Using [pip](https://pip.pypa.io/en/stable/):
```
pip install MedicalImageConverter
```
## Example
The user sets a path to the folder containing the dicom files. If the user already
has each file path then they can continue to *DicomReader*, however if the user
doesn't then use the *file_parsar* function. *file_parsar* will look through all
the files inside the given file path and output a dictionary containing file paths
for these types found:
1. Dicom (.dcm)
2. MetaHeader (.mhd)
3. Raw (.raw)
4. STL (.stl)
In the example below I used *file_parsar*, output the results into
*file_dictionary*. Then the Dicom list was selected for the dictionary which was
input into *DicomReader* class. Lastly, the data is then loaded in using
*load_dicom*.
Note: The *exclude_files* allows the user not to get the file paths for any files
inside the list, generally the user will use an empty list. The
*existing_image_info* is required when the user is trying to load in an RTSTRUCT
file only, some tags are needed for the image it references to create a 3D volume
with the correct spacing.
```python
import MedicalImageConverter as mic
path = r'/path/to/folder'
exclude_files = []
existing_image_info = None
file_dictionary = mic.file_parsar(path, exclude_files)
dicom_reader = mic.DicomReader(file_dictionary['Dicom'], existing_image_info)
dicom_reader.load_dicom()
```
### Retrieve image information:
```python
image_data = dicom_reader.get_image_data() # Returns a list of 3D arrays containing each image
image_info = dicom_reader.get_image_info() # Returns a pandas dataframe containing important tag information
```
Tags in *image_info*:
<span style="font-size:.8em;">FilePath, SOPInstanceUID, PatientID,
PatientName, Modality, SeriesDescription, SeriesDate, SeriesTime,
SeriesInstanceUID, SeriesNumber, AcquisitionNumber, SliceThickness,
PixelSpacing, Rows, Columns, PatientPosition, ImagePositionPatient,
ImageOrientationPatient, Slices, DefaultWindow, FullWindow</span>
### Retrieve ROI information:
```python
roi_data = dicom_reader.get_roi_contour() # Returns a list of lists containing each ROI contour per image
roi_info = dicom_reader.get_roi_info() # Returns a pandas dataframe containing important tag information
```
Tags in *roi_info*:
<span style="font-size:.8em;">FilePath, RoiNames</span>
### Retrieve Sorted Files
```python
ds_images = dicom_reader.get_ds_images() # Returns a list of dicom files sorted into each image
```
Raw data
{
"_id": null,
"home_page": "https://github.com/caleb-oconnor/MedicalImageConverter",
"name": "MedicalImageConverter",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": null,
"author": "Caleb OConnor",
"author_email": "csoconnor@mdanderson.org",
"download_url": "https://files.pythonhosted.org/packages/72/4a/720b72fee57657a1385375d4b8d23587e2b7f2bd9e4362ba1e0e35ab15ae/medicalimageconverter-1.8.tar.gz",
"platform": null,
"description": "\r\n# MedicalImageConverter\r\n\r\n*MedicalImageConverter* is a Python package for working with medical image files. It\r\nlets the user read in images or ROIs (regions of interest), and converts them to 3D\r\nnumpy arrays. It also allows the user to input non-organized datasets (multiple images \r\ninside a single folder). Currently, this module only works for Dicom data with the hopes of expanding to \r\nother data formats in the future. \r\n\r\nThe module currently imports 9 different modalites and RTSTRUCT files. The accepted\r\nmodalites are:\r\n1. CT\r\n2. MR\r\n3. US\r\n4. PT\r\n5. MG\r\n6. DX\r\n7. NM\r\n8. XA\r\n9. CR\r\n\r\nThe CT and MR modalities have been tested extensively, along with their respective\r\nROIs. The other 7 modalities have been tested but only on a few datasets a piece.\r\nFor RTSTRUCTS, only those referencing CT and MR have been tested.\r\n\r\nThe images will be converted to Head-First-Supine (if not so already), and the \r\nimage position will be updated to reflect the needed rotations.\r\n\r\nDisclaimer: All the files will be loaded into memory so be sure you have enough \r\nRAM available. Meaning don't select a folder path that contains 10s of different \r\npatient folders because you could possibly run out of RAM. Also, this module does \r\nnot distinguish between patient IDs or patient names.\r\n\r\n\r\n## Installation\r\nUsing [pip](https://pip.pypa.io/en/stable/):\r\n```\r\npip install MedicalImageConverter\r\n```\r\n\r\n## Example\r\nThe user sets a path to the folder containing the dicom files. If the user already\r\nhas each file path then they can continue to *DicomReader*, however if the user \r\ndoesn't then use the *file_parsar* function. *file_parsar* will look through all \r\nthe files inside the given file path and output a dictionary containing file paths \r\nfor these types found:\r\n1. Dicom (.dcm)\r\n2. MetaHeader (.mhd)\r\n3. Raw (.raw)\r\n4. STL (.stl)\r\n\r\nIn the example below I used *file_parsar*, output the results into \r\n*file_dictionary*. Then the Dicom list was selected for the dictionary which was \r\ninput into *DicomReader* class. Lastly, the data is then loaded in using \r\n*load_dicom*.\r\n\r\nNote: The *exclude_files* allows the user not to get the file paths for any files\r\ninside the list, generally the user will use an empty list. The \r\n*existing_image_info* is required when the user is trying to load in an RTSTRUCT \r\nfile only, some tags are needed for the image it references to create a 3D volume\r\nwith the correct spacing.\r\n\r\n```python\r\nimport MedicalImageConverter as mic\r\n\r\npath = r'/path/to/folder'\r\n\r\nexclude_files = []\r\nexisting_image_info = None\r\nfile_dictionary = mic.file_parsar(path, exclude_files)\r\ndicom_reader = mic.DicomReader(file_dictionary['Dicom'], existing_image_info)\r\ndicom_reader.load_dicom()\r\n```\r\n\r\n### Retrieve image information:\r\n```python\r\nimage_data = dicom_reader.get_image_data() # Returns a list of 3D arrays containing each image\r\nimage_info = dicom_reader.get_image_info() # Returns a pandas dataframe containing important tag information\r\n```\r\n\r\nTags in *image_info*:\r\n<span style=\"font-size:.8em;\">FilePath, SOPInstanceUID, PatientID,\r\nPatientName, Modality, SeriesDescription, SeriesDate, SeriesTime, \r\nSeriesInstanceUID, SeriesNumber, AcquisitionNumber, SliceThickness,\r\nPixelSpacing, Rows, Columns, PatientPosition, ImagePositionPatient, \r\nImageOrientationPatient, Slices, DefaultWindow, FullWindow</span>\r\n\r\n### Retrieve ROI information:\r\n```python\r\nroi_data = dicom_reader.get_roi_contour() # Returns a list of lists containing each ROI contour per image\r\nroi_info = dicom_reader.get_roi_info() # Returns a pandas dataframe containing important tag information\r\n```\r\n\r\nTags in *roi_info*:\r\n<span style=\"font-size:.8em;\">FilePath, RoiNames</span>\r\n\r\n### Retrieve Sorted Files\r\n```python\r\nds_images = dicom_reader.get_ds_images() # Returns a list of dicom files sorted into each image \r\n```\r\n",
"bugtrack_url": null,
"license": null,
"summary": "Reads in medical images and converts them into numpy arrays.",
"version": "1.8",
"project_urls": {
"Homepage": "https://github.com/caleb-oconnor/MedicalImageConverter"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f2143e2eda556c5c6358d6f2b111747811bd4ec8f63a368f569650628723647f",
"md5": "01d3575837eb3d994df322ef30b46e07",
"sha256": "218a74cc824f28c9b64792d33ace20d25082fc5022d5dc4ed5b8bd913faf8de4"
},
"downloads": -1,
"filename": "MedicalImageConverter-1.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "01d3575837eb3d994df322ef30b46e07",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 25560,
"upload_time": "2024-09-09T22:02:11",
"upload_time_iso_8601": "2024-09-09T22:02:11.123439Z",
"url": "https://files.pythonhosted.org/packages/f2/14/3e2eda556c5c6358d6f2b111747811bd4ec8f63a368f569650628723647f/MedicalImageConverter-1.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "724a720b72fee57657a1385375d4b8d23587e2b7f2bd9e4362ba1e0e35ab15ae",
"md5": "7f2001861660ecb33c48db2203812c37",
"sha256": "75471e4f7d27a1f4614306593944e1a9d9a02bc09c0f1e013001a7029cf38cd4"
},
"downloads": -1,
"filename": "medicalimageconverter-1.8.tar.gz",
"has_sig": false,
"md5_digest": "7f2001861660ecb33c48db2203812c37",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 24214,
"upload_time": "2024-09-09T22:02:12",
"upload_time_iso_8601": "2024-09-09T22:02:12.724623Z",
"url": "https://files.pythonhosted.org/packages/72/4a/720b72fee57657a1385375d4b8d23587e2b7f2bd9e4362ba1e0e35ab15ae/medicalimageconverter-1.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-09 22:02:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "caleb-oconnor",
"github_project": "MedicalImageConverter",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "medicalimageconverter"
}