PWV-3: Creating ohif:log package and partially refactoring ohif:measurements

This commit is contained in:
Bruno Alves de Faria authored and Erik Ziegler committed 2016-11-15 08:21:46 +01:00
1 parent f3f32518c6
commit 60aa1d0982
76 files changed
+410 -479

No files matched your search

@@ -1,3 +1,5 @@
import { OHIF } from 'meteor/ohif:core';
// Create a client-only Collection to store our Validation Errors
ValidationErrors = new Meteor.Collection(null);
ValidationErrors._debugName = 'ValidationErrors';
@@ -55,7 +57,7 @@ function addValidationErrorsToCollection(validationErrors, prefix, type) {
* @returns {Array} Array of error messages related to the input conformance checks
*/
function assessGroupOfMeasurements(constraints) {
log.info('assessGroupOfMeasurements');
OHIF.log.info('assessGroupOfMeasurements');
// Retrieve the group-level constraints
var groupConstraints = constraints.group;
@@ -95,7 +97,7 @@ function assessGroupOfMeasurements(constraints) {
* @returns {Array} Array of error messages related to the input conformance checks
*/
function assessMeasurementPerOrgan(constraints) {
log.info('assessMeasurementPerOrgan');
OHIF.log.info('assessMeasurementPerOrgan');
// Retrieve the per-organ constraints
var perOrganConstraints = constraints.perOrgan;
@@ -154,7 +156,7 @@ function assessMeasurementPerOrgan(constraints) {
* @returns {Array} Array of error messages related to the input conformance checks
*/
function assessSingleMeasurement(constraints, measurementData) {
log.info('assessSingleMeasurement');
OHIF.log.info('assessSingleMeasurement');
// Check whether this is a Target or Non-Target Measurement
var targetType = measurementData.isTarget ? 'target' : 'nonTarget';
@@ -262,7 +264,7 @@ function validateSingleMeasurement(measurementData) {
}
function validateGroups() {
log.info('validateGroups');
OHIF.log.info('validateGroups');
// Obtain the names of the current TrialResponseAssessmentCriteria that
// we are using.
@@ -281,7 +283,7 @@ function validateGroups() {
// TODO: Revisit this! We can't use the Timepoints collection inside ANY
// of these functions, since it causes an infinite loop, since Measurement
// validation is performed inside the observe:added hook for the Measurements
// Collection.
// Collection.
var timepointTypes = ['baseline', 'followup'];
timepointTypes.forEach(function(timepointType) {
@@ -1,3 +1,5 @@
import { OHIF } from 'meteor/ohif:core';
// Define the Trial Criteria Structure
TrialCriteriaConstraints = {
RECIST: RECIST,
@@ -148,7 +150,7 @@ function RECIST(image) {
/**
* irRC Trial Criteria Definition
*
*
* Baseline Checks:
* - Target lesions must be >/= 10 X 10 mm
* - Up to a max of 5 target lesions per organ
@@ -376,7 +378,7 @@ getTrialCriteriaConstraints = function(criteriaTypes, imageId) {
const timepoint = timepointApi.study(studyMetaData.studyInstanceUid)[0];
if (!timepoint) {
log.warn('Timepoint related to study is missing.');
OHIF.log.warn('Timepoint related to study is missing.');
return;
}
@@ -1,3 +1,5 @@
import { OHIF } from 'meteor/ohif:core';
clearMeasurementTimepointData = function(measurementId, timepointId) {
var data = Measurements.findOne(measurementId);
@@ -16,7 +18,7 @@ clearMeasurementTimepointData = function(measurementId, timepointId) {
};
function removeToolDataWithMeasurementId(imageId, toolType, measurementId) {
log.info('removeToolDataWithMeasurementId');
OHIF.log.info('removeToolDataWithMeasurementId');
var toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.toolState;
// Find any related toolData
@@ -39,8 +41,8 @@ function removeToolDataWithMeasurementId(imageId, toolType, measurementId) {
}
});
log.info('Removing Indices: ');
log.info(toRemove);
OHIF.log.info('Removing Indices: ');
OHIF.log.info(toRemove);
// If any toolData entries need to be removed, splice them from
// the toolData array
@@ -1,3 +1,5 @@
import { OHIF } from 'meteor/ohif:core';
var responseTypes = {
crTool: 'CR',
exTool: 'EX',
@@ -16,7 +18,7 @@ convertNonTarget = function(measurementApi, measurementData, newTooltype) {
});
if (timepoint && timepoint.timepointType !== 'followup') {
log.warn('Not a followup');
OHIF.log.warn('Not a followup');
return;
}
@@ -1,44 +0,0 @@
/**
* Calculates a Timepoint's name based on how many timepoints exist between it
* and the latest Baseline. Names returned are in the form of 'Baseline', or
* 'Follow-up 1', 'Follow-up 2', and so on.
*
* @param timepoint
* @returns {*} The timepoint name
*/
getTimepointName = function(timepoint) {
// Check if this is a Baseline timepoint, if it is, return 'Baseline'
if (timepoint.timepointType === 'baseline') {
return 'Baseline';
}
// Retrieve all of the relevant follow-up timepoints for this patient
var followupTimepoints = Timepoints.find({
patientId: timepoint.patientId,
timepointType: timepoint.timepointType
}, {
sort: {
latestDate: 1
}
});
// Create an array of just timepointIds, so we can use indexOf
// on it to find the current timepoint's relative position
var followupTimepointIds = followupTimepoints.map(function(timepoint) {
return timepoint.timepointId;
});
// Calculate the index of the current timepoint in the array of all
// relevant follow-up timepoints
var index = followupTimepointIds.indexOf(timepoint.timepointId) + 1;
// If index is 0, it means that the current timepoint was not in the list
// Log a warning and return here
if (!index) {
log.warn('Current follow-up was not in the list of relevant follow-ups?');
return;
}
// Return the timepoint name as 'Follow-up N'
return 'Follow-up ' + index;
};
@@ -1,5 +1,7 @@
import { OHIF } from 'meteor/ohif:core';
pixelSpacingAutorunCheck = function() {
log.info('lesionTool button change autorun');
OHIF.log.info('lesionTool button change autorun');
// Get oncology tools
var oncologyTools = $('button#lesion, button#nonTarget');
@@ -33,4 +35,4 @@ pixelSpacingAutorunCheck = function() {
oncologyTools.prop('disabled', false);
}
};
};
@@ -1,3 +1,5 @@
import { OHIF } from 'meteor/ohif:core';
/**
* Opens a new tab in the tabbed studylist environment using
* a given timepoint and new tab title.
@@ -12,7 +14,7 @@ openNewTabWithTimepoint = function(timepointId, title) {
const timepoint = Timepoints.findOne({
timepointId: timepointId
});
if (!timepoint) {
throw 'No such timepoint exists';
}
@@ -73,7 +75,7 @@ function getDataFromTimepoint(timepoint) {
relatedStudies = relatedStudies.concat(baseline.studyInstanceUids[0]);
timepointIds.push(baseline.timepointId);
} else {
log.warn('No Baseline found while opening a Follow-up Timepoint');
OHIF.log.warn('No Baseline found while opening a Follow-up Timepoint');
}
timepointIds.push(timepoint.timepointId);
@@ -1,10 +1,12 @@
import { OHIF } from 'meteor/ohif:core';
function toolDataExists(toolState, imageId, toolType) {
const currentToolState = toolState[imageId][toolType];
return (currentToolState && currentToolState.data && currentToolState.data.length);
}
syncMeasurementAndToolData = function(measurement) {
log.info('syncMeasurementAndToolData');
OHIF.log.info('syncMeasurementAndToolData');
const toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.toolState;
const imageId = measurement.imageId;
@@ -57,4 +59,4 @@ syncMeasurementAndToolData = function(measurement) {
// Add the MeasurementData into the toolData for this imageId
toolState[imageId][toolType].data.push(measurement);
};
};