1 / 3

Outline of the Objects used in Analysis

Outline of the Objects used in Analysis. Base Classes (module). Utilities/Helpers (module). Compound Classes (module). MrsData (mrs_data) Isa: MrsPack Container for MRS data. Reads many formats in, writes out only VAXML. MrsPack (mrs_pack)

sirius
Télécharger la présentation

Outline of the Objects used in Analysis

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Outline of the Objects used in Analysis Base Classes (module) Utilities/Helpers (module) Compound Classes (module) MrsData (mrs_data) Isa: MrsPack Container for MRS data. Reads many formats in, writes out only VAXML MrsPack (mrs_pack) Class that provides an object the ability to parse itself into a dict format that an ElementTree object can save out to XML MrsProcess (mrs_process) Isa: MrsData Hasa: tdfd = MrsTdfd ecc = MrsEcc svd = MrsHlsvd base = MrsBase Complete collection of parameters and results for spectral processing of MRS data from time to frequency domains MrsTdfd (mrs_tdfd) Parameters and results for time to frequency domain processing util_vasf_file Utility functions for read, write and parse of VA San Francisco (VASF) format MRI/MRS files MrsBase (mrs_base) Parameters and results for freq domain baseline estimates util_vaxml_file Utility functions for read, write and parse of Vespa Analysis XML (VAXML) format MRS files MrsFitting (mrs_fitting) Isa: MrsProcess Hasa: model = MrsVoigt Parameters, provenance and results for spectral processing and fitting of MRS data from time to frequency domains and parametric modeling of metabolites iterated with a non-parametric estimate of baseline signal contributions MrsHlsvd (mrs_hlsvd) Parameters and results for SVD analysis of time domain data util_mrs_file Helper functions to parse elements in the VASF and VAXML utility functions MrsEcc (mrs_ecc) Parameters and results for eddy current correction of time data MrsVoigt (mrs_voigt) Parameters and results for Voigt model metabolite fits iterated with wavelet or spline baseline estimates for spectral analysis NB. The SVD Mode in Analysis makes use of the object in the svd attribute in the MrsProcess object for all of its display and calculations

  2. MrsProcess isa MrsData isa UtilPack Attributes: param1 param2 param3 param4 result1 tdfd ecc base svd MrsTdfd isa UtilPack MrsEcc isa UtilPack MrsBase isa UtilPack MrsHlsvd isa UtilPack Vespa Analysis XML (VAXML) Output Format The purpose of the VAXML format is to be able to represent the objects used in the Analysis application as XML files that can subsequently be read back into the program to reconstitute an object that has data identical to the original. That is, the inherent object IDs may differ, but the data contained within would be the same. The usage of the VAXML format will be two-fold. First, as stated above, object can be stored as XML files and then recreated. This allows data, parameters and results to be stored locally or shared with others using the Analysis program. Second, because each object is stored in a different XML node, the parameters in those nodes can serve as “presets” for the Analysis GUI. Each object saved to an XML file is saved in its own node. Objects that are contained by other objects are nodes within nodes in the XML. For example, the <MrsProcess> node contains an <svd> node, because there is an attribute in MrsProcess called ‘svd’ that has an MrsHlsvd object in it. Each XML sub-node contains both the name of the class within as well as the parameters and results for reconstituting the object. This will allow us flexibility in the future as we add multiple algorithms to any given processing step. We can then create unique class names for each one and just swap out which object type is attached to a given attribute. <MrsProcess> <param1>False</param1> <param2>[4096, 1, 1, 1]</param2> <param3>0.0</param3> <param4>C:\bsoher\Press_CP0.rsd</param4> <result1> parameters describing data data encoded “xdr zip base64 </result1> <tdfd> <MrsTdfd> <param1>[False, False, False]</param1> . . . <paramN>[1, 1, 1]</paramN> <result1> parameters describing data data encoded “xdr zip base64 </result1> </MrsTdfd> </tdfd> <ecc> <MrsEcc> <param1>None</param1> . . . <paramN>-87.81299</parmaN> <result1> parameters describing data data encoded “xdr zip base64 </result1> </MrsEcc> </ecc> <base> <MrsBase> <param1>6</param1> . . . <paramN>None</paramN> </MrsBase> </base> <svd> <MrsHlsvd> <param1>None</param1> . . . <paramN>{}</parmaN> <result1> parameters describing data data encoded “xdr zip base64 </result1> </MrsHlsvd> </svd> </MrsProcess>

  3. VAXML Output Format (cont’d) Parameter Attributes versus Results Attributes Storage There are two types of attributes saved from any given object, “parameters” and “results”. They can be classified generally into “input” and “output” values for the algorithm expressed by the object, respectively. ”Parameters” are generally small collections of values and are stored in typical Python objects, e.g. a list of ten floating point numbers, a boolean flag, a string with a file name, etc. These are saved in VAXML as str() representations of each attribute because they are not unreasonably large and do not have major issues with loss of precision in their conversion. ”Results” data are typically large (they scale with the data being acted upon) and they need to maintain the precision of their values. Results are typically stored as numpy.ndarray objects. For data with spatial dimensions (e.g. a 16x16 matrix in the x- and y-directions where each location contains a 1024 complex array representing an MR spectrum), results will typically have the same spatial dimensions plus the dimensionality of the result itself (e.g. the above mentioned data might have a result that requires three floating point numbers to express, thus the result array would be 16x16x3 of floats). For results arrays with immutable dimensions, e.g. a B0 shift result always has only 1 float result at each spatial location, the entire numpy.ndarray can be flattened, encoded into a single (very long) string of characters, and stored in an XML node with other tag/parameters that allow it to be unencoded later. This method preserves precision while also minimizing the XML file size. Some results have mutable dimensions. One example is the HLSVD algorithm which may require between 10-30 elements in a model to properly express the data in an MR spectrum. The results for this object have the same spatial dimensionality, but the final dimension may have differing numbers of floats in it. These results are stored in 3D lists (representing the x,y,z spatial location) where each x,y,z location has a numpy.ndarray in it. To minimize the space required for these results while maintaining precision, we encode each numpy.ndarray as above, but save them into a 1D list. This list of encoded strings is saved to the results node with other tags/parameters that allow it to be unencoded and reconstituted later. How the MrsPack Class Allows an Object to Desiccate and Reconstitute Itself The MrsPack class is in the vespa.libduke_mr.mrs_pack module. It is inherited into all the data objects used in the Analysis application. This class contains the MrsPack.desiccate() and MrsPack.reconstitute() methods. When called, desiccate() parses the calling object’s attributes (self.__dict__.keys()) and enters an XML compatible representation for each one into a dictionary. Simple “parameter” attributes are saved as str() representations. MrsPack has a list of “special” objects that require more complex representations. Examples of these are numpy.ndarray and other Analysis data objects (MrsData, MrsTdfd, MrsBase, MrsEcc and MrsSvd) which need to be stored in their own nodes and may contain both “parameter” and “results” types of data of their own. MrsPack is also aware of certain attributes in each object that do not need to be parsed into the XML file, e.g. the self.parent attribute is assigned at run time. MrsPack contains code to parse each one of the special objects found in Analysis. In many cases, the base MrsPack.desiccate() method is just called for the object, which results in a dictionary describing the object. This is entered into the original object’s “desiccate dictionary” resulting in a dictionary of dictionaries. In other cases, an object-specific set of rules are coded. [At the moment, object-specific code is centralized in the MrsPack object, but could be pushed into each specific object by overwriting its desiccate() method.] The user can then convert the resultant dictionary of the desiccate method into an ElementTree object (using the mrs_pack.ConvertDictToXml() function) and write it out to an XML file. MrsPack uses a vespa.common.ordered_dict object to try to make the final XML a bit more human readable. The ordered_dict object allows “parameter” entries to be stored before the “results” entries (which may have very long encoded strings. Thus the human readable values should be at the top of each node.

More Related