OHIF-20 Documentation for parsingUtils.js library...
This commit is contained in:
parent
1122594d2b
commit
7d199ab462
@ -1,10 +1,29 @@
|
||||
|
||||
import {dicomParser} from 'meteor/cornerstone';
|
||||
|
||||
/**
|
||||
* A small set of utilities to help parsing DICOM element values.
|
||||
* In the future the functionality provided by this library might
|
||||
* be incorporated into dicomParser library.
|
||||
*/
|
||||
|
||||
export const parsingUtils = {
|
||||
|
||||
/**
|
||||
* Check if supplied argument is a valid instance of the dicomParser.DataSet class.
|
||||
* @param data {Object} An instance of the dicomParser.DataSet class.
|
||||
* @returns {Boolean} Returns true if data is a valid instance of the dicomParser.DataSet class.
|
||||
*/
|
||||
isValidDataSet: function(data) {
|
||||
return (data instanceof dicomParser.DataSet);
|
||||
},
|
||||
|
||||
/**
|
||||
* Parses an element tag according to the 'AT' VR definition.
|
||||
* @param data {Object} An instance of the dicomParser.DataSet class.
|
||||
* @param tag {String} A DICOM tag with in the format xGGGGEEEE.
|
||||
* @returns {String} A string representation of a data element tag or null if the field is not present or data is not long enough.
|
||||
*/
|
||||
attributeTag: function(data, tag) {
|
||||
if (this.isValidDataSet(data) && tag in data.elements) {
|
||||
let element = data.elements[tag];
|
||||
@ -17,6 +36,15 @@ export const parsingUtils = {
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Parses the string representation of a multi-valued element into an array of strings. If the parser
|
||||
* parameter is passed and is a function, it will be applied to each element of the resulting array.
|
||||
* @param data {Object} An instance of the dicomParser.DataSet class.
|
||||
* @param tag {String} A DICOM tag with in the format xGGGGEEEE.
|
||||
* @param parser {Function} An optional parser function that can be applied to each element of the array.
|
||||
* @returns {Array} An array of floating point numbers or null if the field is not present or data is not long enough.
|
||||
*/
|
||||
multiValue: function(data, tag, parser) {
|
||||
if (this.isValidDataSet(data) && tag in data.elements) {
|
||||
let element = data.elements[tag];
|
||||
@ -35,7 +63,15 @@ export const parsingUtils = {
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Parses a string to an array of floats for a multi-valued element.
|
||||
* @param data {Object} An instance of the dicomParser.DataSet class.
|
||||
* @param tag {String} A DICOM tag with in the format xGGGGEEEE.
|
||||
* @returns {Array} An array of floating point numbers or null if the field is not present or data is not long enough.
|
||||
*/
|
||||
floatArray: function(data, tag) {
|
||||
return this.multiValue(data, tag, parseFloat);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user