London useR Meeting 21-Jul-09

  • Published on

  • View

  • Download

Embed Size (px)


<ul><li> 1. Developing S4 Classes for Medical Imaging Data Initial Experience(s)Brandon Whitcher, PhDGlaxoSmithKlineClinical Imaging Centre </li></ul> <p> 2. Acknowledgements S4 Classes and Methods Slides by F. Leisch and P. Murrell Software for Data Analysis by J. Chambers R Programming for Bioinformatics by R. Gentlemen R packages nlme kernlab EBImage2 3. OOP and Classes in R One identifies real objects, and the operations on them, that are interesting. These operations can be systematically implemented. A basic principle (hope) is that by faithfully representing the objects we get easier-to-implement functions. A class is an abstract definition of a concrete real-world object. A class system is a software infrastructure that is designed to help construct classes and to provide programmatic support for dealing with classes. 3 4. Why (S4) Classes for Medical Imaging Data? Context of imaging data Interface with data standards and third-party software Numerous processing steps involved Multiple information sources Audit trail (internal and external agencies) Too easy to make mistakes! 4 5. Data Analysis PipelineTest statisticsMotion correction Model building p-valuesWarpingParameter Multiple Co-registration estimation comparisons DataMathematical StatisticalPre-processing Modelling AnalysisResults 5 6. Medical Imaging DataSlice Thickness; e.g. 5mmZ Y XXChosen parameters dependSpatial Resolution on many factors: application,Size = X Y; e.g. 256256 scanner, local practice, radiologist preferences, etc. e.g. 0.4mm 6 7. Composition of Structural DataNIfTI 3Dconvert Z X Y7 DICOM 8. Composition of Dynamic Data Z ZNIfTI 4DX XY Yt=1 t=T8 9. The nifti Class Inherits from class array Contains 44 slots (not counting .Data) both numeric and character strings [348 bytes]setClass(nifti, representation(sizeof_hdr=numeric, data_type=character, ...),prototype(sizeof_hdr=348,data_type=,...),contains=array) Also created function nifti() for user-defined slots. Similar class has been defined for ANALYZE data. 9 10. Method show for nifti Class setMethod(show, nifti, function(object) { cat(NIfTI-1 file format, fill=TRUE) cat(...) cat(...) })&gt; ffd NIfTI-1 format Type: nifti Data Type : 4 (INT16) Bits per Pixel: 16 Slice Code: 0 (Unknown) Intent Code : 0 (None) Qform Code: 1 (Scanner_Anat) Sform Code: 0 (Unknown) Dimension : 64 x 64 x 21 x 180 Pixel Dimension : 4 x 4 x 6 x 3 Voxel Units : mm Time Units: sec10 11. Validity Checking for nifti Class setValidity(nifti, function(object) { retval descrip(mniLR) [1] "FSL3.2beta"[1] "FSL3.2beta" Replacement functions setMethod(descrip, nifti, function(object) { object@descrip }) setGeneric(descrip</p>