Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/scripts_md/MRI.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ INPUTS:

RETURNS: textual name of scan type from the `mri_scan_type` table

### insert\_violated\_scans($dbhr, $series\_desc, $minc\_location, $patient\_name, $candid, $pscid, $visit, $tr, $te, $ti, $slice\_thickness, $xstep, $ystep, $zstep, $xspace, $yspace, $zspace, $time, $seriesUID, $data\_dir)
### insert\_violated\_scans($dbhr, $series\_desc, $minc\_location, $patient\_name, $candid, $pscid, $visit, $tr, $te, $ti, $slice\_thickness, $xstep, $ystep, $zstep, $xspace, $yspace, $zspace, $time, $seriesUID, $echo\_numbers, $phase\_enc\_dir, $data\_dir, $mriProtocolGroupID)

Inserts scans that do not correspond to any of the defined protocol from the
`mri_protocol` table into the `mri_protocol_violated_scans` table of the
Expand Down Expand Up @@ -116,6 +116,8 @@ INPUTS:
- $tarchiveID : `TarchiveID` of the DICOM archive from which this file is derived
- $image\_type : the `image_type` header value of the image
- $data\_dir : path to the LORIS MRI data directory
- $echo\_numbers : `echo_numbers` of the image (a.k.a. `dicom_0x0018:el_0x0086` header)
- $phase\_enc\_dir : `phase_encoding_direction` of the image
- $mriProtocolGroupID : ID of the protocol group used to try to identify the scan.

### scan\_type\_id\_to\_text($typeID, $db)
Expand Down
10 changes: 9 additions & 1 deletion python/lib/imaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ def insert_protocol_violated_scan(self, patient_name, cand_id, psc_id, tarchive_
:type mri_protocol_group_id: int
"""

phase_encoding_dir = scan_param["PhaseEncodingDirection"] if "PhaseEncodingDirection" in scan_param else None

info_to_insert_dict = {
"CandID": cand_id,
"PSCID": psc_id,
Expand All @@ -218,8 +220,10 @@ def insert_protocol_violated_scan(self, patient_name, cand_id, psc_id, tarchive_
"ystep_range": scan_param["ystep"] if "ystep" in scan_param.keys() else None,
"zstep_range": scan_param["zstep"] if "zstep" in scan_param.keys() else None,
"time_range": scan_param["time"] if "time" in scan_param.keys() else None,
"SeriesUID": scan_param["SeriesUID"] if "SeriesUID" in scan_param.keys() else None,
"SeriesUID": scan_param["SeriesInstanceUID"] if "SeriesInstanceUID" in scan_param.keys() else None,
"image_type": str(scan_param["ImageType"]) if "ImageType" in scan_param.keys() else None,
"PhaseEncodingDirection": phase_encoding_dir,
"EchoNumber": repr(scan_param["EchoNumber"]) if "EchoNumber" in scan_param else None,
"MriProtocolGroupID": mri_protocol_group_id if mri_protocol_group_id else None
}
self.mri_prot_viol_scan_db_obj.insert_protocol_violated_scans(info_to_insert_dict)
Expand Down Expand Up @@ -636,6 +640,8 @@ def is_scan_protocol_matching_db_protocol(self, db_prot, scan_param):
scan_ti = scan_param['InversionTime'] * 1000 if 'InversionTime' in scan_param else None
scan_slice_thick = scan_param['SliceThickness']
scan_img_type = str(scan_param['ImageType'])
scan_ped = scan_param['PhaseEncodingDirection'] if 'PhaseEncodingDirection' in scan_param else None
scan_en = scan_param['EchoNumber'] if 'EchoNumber' in scan_param else None

if (self.in_range(scan_param['time'], db_prot['time_min'], db_prot['time_max'])) \
and self.in_range(scan_tr, db_prot['TR_min'], db_prot['TR_max']) \
Expand All @@ -648,6 +654,8 @@ def is_scan_protocol_matching_db_protocol(self, db_prot, scan_param):
and self.in_range(scan_param['yspace'], db_prot['yspace_min'], db_prot['yspace_max']) \
and self.in_range(scan_param['zspace'], db_prot['zspace_min'], db_prot['zspace_max']) \
and self.in_range(scan_slice_thick, db_prot['slice_thickness_min'], db_prot['slice_thickness_max'])\
and (not db_prot['PhaseEncodingDirection'] or scan_ped == db_prot['PhaseEncodingDirection'])\
and (not db_prot['EchoNumber'] or scan_en == int(db_prot['EchoNumber']))\
and (not db_prot['image_type'] or scan_img_type == db_prot['image_type']):
return True

Expand Down
Loading