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';
TrialCriteriaTypes = new Meteor.Collection(null);
TrialCriteriaTypes.insert({
@@ -54,7 +56,7 @@ Template.optionsModal.events({
'click a.clearAllStudyTimepointAssociations': function() {
Meteor.call('clearAllTimepoints', function(error) {
if (error) {
log.warn(error);
OHIF.log.warn(error);
}
});
}
@@ -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);
};
};
-3
View File
@@ -1,3 +0,0 @@
// Create package logger using loglevel
// https://atmospherejs.com/spacejamio/loglevel
log = loglevel.createPackageLogger('lesiontracker', defaultLevel = 'info');
+3 -11
View File
@@ -15,9 +15,6 @@ Package.onUse(function(api) {
api.use('validatejs');
// Control over logging
api.use('practicalmeteor:loglevel');
// Template overriding
api.use('aldeed:template-extension@4.0.0');
@@ -28,14 +25,12 @@ Package.onUse(function(api) {
api.use('ohif:cornerstone');
api.use('ohif:measurements');
api.addFiles('log.js', [ 'client', 'server' ]);
api.addFiles('both/configuration/bidirectional.js', [ 'client', 'server' ]);
api.addFiles('both/configuration/nonTarget.js', [ 'client', 'server' ]);
api.addFiles('both/configuration/ellipse.js', [ 'client', 'server' ]);
api.addFiles('both/configuration/length.js', [ 'client', 'server' ]);
api.addFiles('both/configuration/measurementTools.js', [ 'client', 'server' ]);
api.addFiles('both/configuration/dataExchange.js', [ 'client', 'server' ]);
api.addFiles('both/configuration/dataValidation.js', [ 'client', 'server' ]);
api.addFiles('both/configuration/configuration.js', [ 'client', 'server' ]);
@@ -72,7 +67,7 @@ Package.onUse(function(api) {
api.addFiles('client/components/measurementLocationDialog/measurementLocationDialog.html', 'client');
api.addFiles('client/components/measurementLocationDialog/measurementLocationDialog.js', 'client');
api.addFiles('client/components/measurementLocationDialog/measurementLocationDialog.styl', 'client');
api.addFiles('client/components/nonTargetLesionDialog/nonTargetLesionDialog.html', 'client');
api.addFiles('client/components/nonTargetLesionDialog/nonTargetLesionDialog.styl', 'client');
api.addFiles('client/components/nonTargetLesionDialog/nonTargetLesionDialog.js', 'client');
@@ -92,7 +87,7 @@ Package.onUse(function(api) {
// Library functions
api.addFiles('lib/TrialCriteriaConstraints.js', 'client');
api.addFiles('lib/MeasurementValidation.js', 'client');
api.addFiles('lib/pixelSpacingAutorunCheck.js', 'client');
api.addFiles('lib/toggleLesionTrackerTools.js', 'client');
api.addFiles('lib/clearMeasurementTimepointData.js', 'client');
@@ -106,9 +101,6 @@ Package.onUse(function(api) {
api.export('syncMeasurementAndToolData', 'client');
api.export('syncImageMeasurementAndToolData', 'client');
api.export('openNewTabWithTimepoint', 'client');
api.export('activateLesion', 'client');
api.export('activateMeasurements', 'client');
api.export('deactivateAllToolData', 'client');
api.export('toggleLesionTrackerTools', 'client');
api.export('clearMeasurementTimepointData', 'client');
api.export('getTrialCriteriaConstraints', 'client');