Dicom Reader
Master reader class to crawl through the directory and generate relevant DicomStudy and DicomSeries dataclasses
Source code in pygrpm/dicom/reader.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
|
studies: List[DicomStudy]
property
Property method to get an explicit list of the obtained studies @return: A list of DicomStudy dataclasses for the found studies
studies_UID: List[Union[str, pydicom.uid.UID]]
property
property method to return a list of all instances uid within the series dataclass @return: An similarly ordered list of instances UID
add_instance_in_series(series, dicom)
staticmethod
Method used to add the dicom instance into the series should it not already be present @param series: The DicomSeries to be updated @param dicom: The pydicom filedataset containing the dicom instance @return: The updated DataSeries
Source code in pygrpm/dicom/reader.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
|
add_or_update_series_in_study(study, series)
staticmethod
Method will either append series to the study if it is not already present. Should the series already exist in the study it will be updated @param study: The DicomStudy to be updated @param series: The DicomSeries to place/update within the study @return: The updated DicomStudy
Source code in pygrpm/dicom/reader.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
build_dicom_list()
Method used to navigate through the class folder, ensure the files are dicom, then append the dicoms to a master list for further processing @return: The list of dicom datasets
Source code in pygrpm/dicom/reader.py
70 71 72 73 74 75 76 77 78 79 |
|
build_studies()
Main method used to buildup all the studies and series from the given folder @return: A -> List of studies as obtained from the folder
Source code in pygrpm/dicom/reader.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
get_series(study, series_UID)
Helper method to obtain a DicomSeries class from its DicomStudy @param study: The reference DicomStudy dataclass or associated UID @param series_UID: SeriesInstanceUID @return: The DicomSeries dataclass matching the provided UID
Source code in pygrpm/dicom/reader.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
|
get_study(study_UID)
Helper method to obtain a DicomStudy class from its StudyInstanceUID @param study_UID: StudyInstanceUID @return: The DicomStudy dataclass matching the provided UID
Source code in pygrpm/dicom/reader.py
193 194 195 196 197 198 199 200 201 202 203 |
|
load_dcm(filepath)
Simple wrapper method to cleanly handle non-dicom files within the provided folder @param filepath: path to the potential dicom file @return: The pydicom FileDataset is appropriate, otherwise None
Source code in pygrpm/dicom/reader.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
|
make_series(dicom)
staticmethod
Method to create a DicomSeries dataclass based on the provided dicom dataset @param dicom: The reference dicom dataset @return: The DicomSeries dataclass
Source code in pygrpm/dicom/reader.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
|
make_study(dicom)
staticmethod
Method to create a DicomStudy dataclass based on the provided dicom dataset @param dicom: The reference dicom dataset @return: The DicomStudy dataclass
Source code in pygrpm/dicom/reader.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
|
yield_dicoms()
Generator utilized to obtain the pydicom FileDatasets within the data folder
Source code in pygrpm/dicom/reader.py
56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
Module containing dataclasses to represent and store dicom information
DicomSeries
dataclass
Dataclass meant to contain a Dicom series along with easy access to key values
Source code in pygrpm/dicom/structures.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|
first_instance: pydicom.FileDataset
property
Provide a sample dicom file for tag referencing @return:
instances_UID: List[Union[str, pydicom.uid.UID]]
property
property method to return a list of all instances uid within the series dataclass @return: An similarly ordered list of instances UID
numpy: Union[np.ndarray, None]
property
Returns the volume represented in the list of Instances' pixel_array Volume is in a "slices last" format @return: The associated numpy array if found
get_instance(instance_UID)
Helper method to obtain a Dicom instance (pydicom dataset) from its DicomSeries @param series_UID: SeriesInstanceUID @return: The DicomSeries dataclass matching the provided UID
Source code in pygrpm/dicom/structures.py
98 99 100 101 102 103 104 105 106 107 |
|
sort_instances_by_tag(tag, index=None)
Sort the dicom instance list based on tag @param tag: Dicom tag as represented by pydicom @param index: Index in the tag's tuple/list if relevent @return: None
Source code in pygrpm/dicom/structures.py
85 86 87 88 89 90 91 92 93 94 95 96 |
|
DicomStudy
dataclass
Dataclass to represent a Dicom patient study
Source code in pygrpm/dicom/structures.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
|
modalities: List[str]
property
Property method to obtain all modalities present in the study @return: List of modalities as they appear in pydicom
series_UID: List[Union[str, pydicom.uid.UID]]
property
property method to return a list of all series uid within the study dataclass @return: An similarly ordered list of series UID
filter_by_modality(modality)
Helper method to grab only series of a specific modality from the study @param modality: The dicom modality as it appears in pydicom @return: List of relevant DicomSeries dataclasses
Source code in pygrpm/dicom/structures.py
130 131 132 133 134 135 136 |
|
get_series(series_UID)
Helper method to obtain a DicomSeries class from its DicomStudy @param series_UID: SeriesInstanceUID @return: The DicomSeries dataclass matching the provided UID
Source code in pygrpm/dicom/structures.py
146 147 148 149 150 151 152 153 154 155 |
|
UID Generation module
generate_uid(entropy_sources=None)
Generate a unique DICOM UID with the GRPM prefix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entropy_sources |
Optional[List[str]]
|
The GRPM prefix will be appended with a SHA512 hash of the given list which means the result is deterministic and should make the original data unrecoverable. |
None
|
Returns:
Type | Description |
---|---|
str
|
A DICOM UID of up to 64 characters. |
Source code in pygrpm/dicom/uid.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|