Skip to content

Commit

Permalink
Update API summary header and qc to include more info (aces#4077)
Browse files Browse the repository at this point in the history
Updates to the API v.0.0.3 on the imaging side:

- Addition of scanner information to the summary header of the API for a given filename (manufacturer, model, software version, serial number)
- Addition of the image Caveat flag with the reason for the Caveat flag in the file qc page of the API

Fix to API v0.0.2 on the imaging side:

- The selected were not queried at the right place. The selected has been part of the files_qcstatus for several LORIS releases so updated the API queries so we can grep the Selected flag (before it returned some hash, now it returns True or False)
  • Loading branch information
cmadjar authored and Krishna Chatpar committed Apr 15, 2019
1 parent 3316acd commit 955b675
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 63 deletions.
27 changes: 25 additions & 2 deletions docs/API/LorisRESTAPI_v0.0.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,23 @@ Returns file level QC information. It will return a JSON object of the form:
"File" : $Filename
},
"QC" : "Pass|Fail",
"Selected" : boolean
"Selected" : boolean,
"Caveats" : [
{
"Severity" : $severity,
"Header" : $header,
"Value" : $headerValue,
"ValidRange" : $headerValidRange,
"ValidRegex" : $headerValidRegex
},
{
"Severity" : $severity,
"Header" : $header,
"Value" : $headerValue,
"ValidRange" : $headerValidRange,
"ValidRegex" : $headerValidRegex
}
]
}
```
Expand Down Expand Up @@ -668,7 +684,7 @@ will return a JSON object of the form:
"Description" : {
"SeriesName" : "",
"SeriesDescription" : ""
}
},
"Dimensions" : {
"XSpace" : {
"Length" : "",
Expand All @@ -686,6 +702,13 @@ will return a JSON object of the form:
"Length" : "",
"StepSize" : ""
}
},
"ScannerInfo" : {
"Manufacturer" : $scannerManufacturer,
"Model" : $scannerModel,
"SoftwareVersion" : $scannerSoftwareVersion,
"SerialNumber" : $scannerSerialNumber,
"FieldStrength" : $scannerFieldStrength
}
}
```
Expand Down
14 changes: 7 additions & 7 deletions htdocs/api/v0.0.2/candidates/visits/images/qc/QC.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ public function handleGET()
$factory = \NDB_Factory::singleton();
$DB = $factory->Database();
$QCStatus = $DB->pselectRow(
"SELECT QCStatus,
pf.Value as Selected FROM files f
LEFT JOIN files_qcstatus fqc ON (f.FileID=fqc.FileID)
LEFT JOIN parameter_file pf ON (f.FileID=pf.FileID)
LEFT JOIN parameter_type pt
ON (pf.ParameterTypeID=pt.ParameterTypeID AND pt.Name='Selected')
WHERE f.File LIKE CONCAT('%', :FName)",
"SELECT QCStatus, Selected
FROM files_qcstatus
WHERE FileID in (
SELECT FileID
FROM files
WHERE File LIKE CONCAT('%', :FName)
)",
array('FName' => $this->Filename)
);
$this->JSON = [
Expand Down
99 changes: 56 additions & 43 deletions htdocs/api/v0.0.3-dev/candidates/visits/images/headers/Headers.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,54 +62,67 @@ public function __construct($method, $CandID, $VisitLabel, $Filename)
*/
public function handleGET()
{
$TE = $this->getHeader('acquisition:echo_time');
$TR = $this->getHeader('acquisition:repetition_time');
$TI = $this->getHeader('acquisition:inversion_time');
$ST = $this->getHeader('acquisition:slice_thickness');
$te = $this->getHeader('acquisition:echo_time');
$tr = $this->getHeader('acquisition:repetition_time');
$ti = $this->getHeader('acquisition:inversion_time');
$st = $this->getHeader('acquisition:slice_thickness');

$SeriesName = $this->getHeader("acquisition:protocol");
$SeriesDescription = $this->getHeader("acquisition:series_description");
$seriesName = $this->getHeader("acquisition:protocol");
$seriesDescription = $this->getHeader("acquisition:series_description");

$XSpace = [
"Length" => $this->getHeader("xspace:length"),
"StepSize" => $this->getHeader("xspace:step"),
];
$YSpace = [
"Length" => $this->getHeader("yspace:length"),
"StepSize" => $this->getHeader("yspace:step"),
];
$ZSpace = [
"Length" => $this->getHeader("zspace:length"),
"StepSize" => $this->getHeader("zspace:step"),
];
$TimeD = [
"Length" => $this->getHeader("time:length"),
"StepSize" => $this->getHeader("time:step"),
];
$this->JSON = [
'Meta' => [
$xspace = array(
"Length" => $this->getHeader("xspace:length"),
"StepSize" => $this->getHeader("xspace:step"),
);
$yspace = array(
"Length" => $this->getHeader("yspace:length"),
"StepSize" => $this->getHeader("yspace:step"),
);
$zspace = array(
"Length" => $this->getHeader("zspace:length"),
"StepSize" => $this->getHeader("zspace:step"),
);
$timeD = array(
"Length" => $this->getHeader("time:length"),
"StepSize" => $this->getHeader("time:step"),
);

$manufacturer = $this->getHeader("study:manufacturer");
$model = $this->getHeader("study:device_model");
$softwareVersion = $this->getHeader("study:software_version");
$serialNumber = $this->getHeader("study:serial_no");
$fieldStrength = $this->getHeader("study:field_value");

$this->JSON = array(
'Meta' => array(
'CandID' => $this->CandID,
'Visit' => $this->VisitLabel,
'Filename' => $this->Filename,
],
'Physical' => [
"TE" => $TE,
"TR" => $TR,
"TI" => $TI,
"SliceThickness" => $ST,
],
'Description' => [
"SeriesName" => $SeriesName,
"SeriesDescription" => $SeriesDescription,
],
'Dimensions' => [
"XSpace" => $XSpace,
"YSpace" => $YSpace,
"ZSpace" => $ZSpace,
"TimeDimension" => $TimeD,
],

];
),
'Physical' => array(
"TE" => $te,
"TR" => $tr,
"TI" => $ti,
"SliceThickness" => $st,
),
'Description' => array(
"SeriesName" => $seriesName,
"SeriesDescription" => $seriesDescription,
),
'Dimensions' => array(
"XSpace" => $xspace,
"YSpace" => $yspace,
"ZSpace" => $zspace,
"TimeDimension" => $timeD,
),
'ScannerInfo' => array(
"Manufacturer" => $manufacturer,
"Model" => $model,
"SoftwareVersion" => $softwareVersion,
"SerialNumber" => $serialNumber,
"FieldStrength" => $fieldStrength,
),
);
}

/**
Expand Down
43 changes: 32 additions & 11 deletions htdocs/api/v0.0.3-dev/candidates/visits/images/qc/QC.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,45 @@ public function handleGET()
$factory = \NDB_Factory::singleton();
$DB = $factory->Database();
$QCStatus = $DB->pselectRow(
"SELECT QCStatus,
pf.Value as Selected FROM files f
LEFT JOIN files_qcstatus fqc ON (f.FileID=fqc.FileID)
LEFT JOIN parameter_file pf ON (f.FileID=pf.FileID)
LEFT JOIN parameter_type pt
ON (pf.ParameterTypeID=pt.ParameterTypeID AND pt.Name='Selected')
WHERE f.File LIKE CONCAT('%', :FName)",
"SELECT QCStatus, Selected
FROM files_qcstatus
WHERE FileID in (
SELECT FileID
FROM files
WHERE File LIKE CONCAT('%', :FName)
)",
array('FName' => $this->Filename)
);
$this->JSON = [
'Meta' => [
$caveats = $this->getImageCaveats();
$this->JSON = array(
'Meta' => array(
'CandID' => $this->CandID,
'Visit' => $this->VisitLabel,
'File' => $this->Filename,
],
),
'QC' => $QCStatus['QCStatus'],
'Selected' => $QCStatus['Selected'],
];
'Caveats' => $caveats,
);
}

/**
* Gets the list of Caveats for the file.
*
* @return array A list of caveats for the file
*/
function getImageCaveats(): array
{
$factory = \NDB_Factory::singleton();
$DB = $factory->Database();
$rows = $DB->pselect(
"SELECT Severity, Header, Value, ValidRange, ValidRegex
FROM files f
LEFT JOIN mri_violations_log mvl ON (f.SeriesUID=mvl.SeriesUID)
WHERE f.File LIKE CONCAT('%', :FName)",
array('FName' => $this->Filename)
);
return $rows;
}

/**
Expand Down

0 comments on commit 955b675

Please sign in to comment.