-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* attempted to add DICOM Extraction * changed file name to match class * adding function for mCT metadata extraction * Add parameter extraction code * Delete MetadataExtractor/Extractors/Data/ParameterExtract.py removed superfluous file * Delete MetadataExtractor/Extractors/Data/mCTExtract.py removed superfluous file * Update IDataExtract.py Removed , "dcm" from default * Updated DicomExtract.py to use dicom_metadata Removed the undefined attribute parameter. * adding pydicom, adding DicomExtract to config new file: Examples/2022-03-07_18h21_M3_Cy7.mCT new file: Examples/2022-03-07_18h21_M3_Cy7.parameters new file: Examples/EnIm1.dcm modified: MetadataExtractor/Extractors/Data/DicomExtract.py modified: MetadataExtractor/Extractors/Data/IDataExtract.py deleted: MetadataExtractor/Extractors/Data/ParameterExtract.py deleted: MetadataExtractor/Extractors/Data/mCTExtract.py modified: defaultConfigs.py modified: requirements.txt * dicom extractor appears to work now
- Loading branch information
1 parent
6873e08
commit d1fde15
Showing
6 changed files
with
117 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# mCT settings file v1.0 | ||
|
||
[mCT] | ||
name = FLT totalbody normal | ||
magnification = total_body | ||
scan_angle = 360.000000 | ||
scan_mode = normal | ||
lin_stage_position = -1.000000 | ||
mode = step_and_shoot | ||
angle_start = 0.000000 | ||
angle_speed_deg_s = 0.000000 | ||
angle_step_deg = 0.750000 | ||
binning = x11 | ||
exposure_ms = 75.000000 | ||
frame_averaging = 1 | ||
xray_voltage_kV = 55.000000 | ||
xray_current_mA = 0.170000 | ||
exposure2_ms = 0.000000 | ||
xray_voltage2_kV = 0.000000 | ||
xray_current2_mA = 0.000000 | ||
origin_offset_z = 236.200000 | ||
HU_calibration = 20342.444444 | ||
BeamHardening = 0.245556 | ||
HU_calibration2 = 0.000000 | ||
BeamHardening2 = 0.000000 | ||
NrScans = 1 | ||
gating_proj_per_angle = 1 | ||
filter_1 = Al400 | ||
filter_2 = | ||
fixed_filter = Al 100�m | ||
Pitch (if helical) = 0.000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# U-SPECT parameter file v4.0 | ||
|
||
[System] | ||
ScannerID = "80481" | ||
SoftwareVersion = "12.27-st" | ||
ScannerType = "U-CT" | ||
|
||
[Animal] | ||
ScanID = "2022-03-07_18h21_M3_Cy7" | ||
AnimalID = "SS_FluoInserts" | ||
|
||
[Images] | ||
FovXY_mm = 88.000000 | ||
FovZ_mm = 230.000000 | ||
|
||
[Acquisition] | ||
AcqStartTime = "2022-03-07 18:50:00" | ||
SPECT = 0 | ||
CT = 1 | ||
OI = 0 | ||
FLT = 1 | ||
BLT = 0 | ||
Fluoroscopy = 0 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from .IDataExtract import IDataExtract | ||
from MetadataExtractor.Util import metadataCreation, metadataFormatter | ||
import pydicom | ||
from pathlib import Path | ||
from pydicom._version import __version_info__ | ||
import logging | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
class DicomExtract(IDataExtract): | ||
def extract(self, fileInfo): | ||
log.info('Extracting metadata for Dicom file "' + fileInfo["file"] + '".') | ||
text = "" | ||
|
||
dicom_metadata = pydicom.dcmread(fileInfo["file"]) | ||
|
||
for elem in dicom_metadata.iterall(): | ||
if elem.tag.is_private: | ||
continue # Skip private tags | ||
tag_str = elem.tag | ||
value = elem.value | ||
if isinstance(value, pydicom.valuerep.DSfloat): | ||
value = float(value) | ||
logging.info(dicom_metadata.keys) | ||
# Construct a DataElement instance | ||
data_element = pydicom.DataElement(tag_str, elem.VR, value) | ||
dicom_metadata[tag_str] = data_element | ||
|
||
values = [] | ||
identifier = fileInfo["identifier"] | ||
|
||
for attribute in dicom_metadata.keys(): | ||
objectValue = dicom_metadata[attribute] | ||
values.append( | ||
{ | ||
"predicate": "mexattr:" + metadataFormatter.replaceForbiddenValues(str(attribute)), | ||
"object": objectValue, | ||
} | ||
) | ||
|
||
metadata = metadataCreation.addEntryToFileGraph( | ||
fileInfo, | ||
self._IExtract__config, | ||
{ | ||
"additionalPrefixes": [ | ||
"@prefix dcat: <http://www.w3.org/ns/dcat#>", | ||
"@prefix dcterms: <http://purl.org/dc/terms/>", | ||
], | ||
"identifier": identifier, | ||
"ontology": "mex", | ||
"values": values, | ||
}, | ||
) | ||
|
||
return (text, metadata) | ||
|
||
def registerMimeTypes(self): | ||
self.mimeTypes["concrete"] = ["application/dcm", "application/dicom"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,4 +52,5 @@ pandas==1.5.1 | |
flowkit==1.0.0 | ||
openai-whisper | ||
soundfile | ||
pefile==2023.2.7 | ||
pefile==2023.2.7 | ||
pydicom==2.4.4 |