{"id":5938,"date":"2015-04-10T09:00:28","date_gmt":"2015-04-10T13:00:28","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=5938"},"modified":"2015-04-08T22:42:39","modified_gmt":"2015-04-09T02:42:39","slug":"structure-display","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2015\/04\/10\/structure-display\/","title":{"rendered":"Structure Display"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <introduction>\r\n      <p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3208495\">Sean<\/a>'s pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/13831-structure-display\">Structure Display<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/898621\">Thomas Deneux<\/a>.\r\n      <\/p>\r\n   <\/introduction>\r\n   <h3>Contents<\/h3>\r\n   <div>\r\n      <ul>\r\n         <li><a href=\"#1\">Structures in MATLAB<\/a><\/li>\r\n         <li><a href=\"#4\">Metadata<\/a><\/li>\r\n         <li><a href=\"#6\">Regular Display<\/a><\/li>\r\n         <li><a href=\"#7\">fn_structdisp Display<\/a><\/li>\r\n         <li><a href=\"#9\">Comments<\/a><\/li>\r\n      <\/ul>\r\n   <\/div>\r\n   <h3>Structures in MATLAB<a name=\"1\"><\/a><\/h3>\r\n   <p>A structure in MATLAB is a container for heterogenous data that you reference by a name.  Let's take a look at a simple structure:\r\n      we will reference two fields of <i>S<\/i> named <i>A<\/i> and <i>B<\/i> (I don't win too many awards for creativity!).\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">S.A = <span style=\"color: #A020F0\">'Hello World'<\/span>;\r\nS.B = pi;\r\ndisp(S)<\/pre><pre style=\"font-style:oblique\">    A: 'Hello World'\r\n    B: 3.1416\r\n<\/pre><p>This level of display is sufficient for a simple structure.  But what about a more complex structure with possibly nested\r\n      structures inside of it?\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">S.C = S; <span style=\"color: #228B22\">% insert S into one field of S, structure inception?<\/span>\r\ndisp(S)<\/pre><pre style=\"font-style:oblique\">    A: 'Hello World'\r\n    B: 3.1416\r\n    C: [1x1 struct]\r\n<\/pre><p>The built in display of the structure shows the high-level summary of the fields it contains, not the detailed version which\r\n      could be complex. Sometimes this additional information is useful, especially for debugging.\r\n   <\/p>\r\n   <p>Here's the display with <tt>fn_structdisp<\/tt><\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">fn_structdisp(S);<\/pre><pre style=\"font-style:oblique\">S:\r\n    A: 'Hello World'\r\n    B: 3.1416\r\n    C: [1x1 struct]\r\nS.B:\r\n    3.1416\r\nS.C:\r\n    A: 'Hello World'\r\n    B: 3.1416\r\nS.C.B:\r\n    3.1416\r\n<\/pre><h3>Metadata<a name=\"4\"><\/a><\/h3>\r\n   <p>One of the places this type of display is really useful is when looking at metadata for files where the meta data can be logically\r\n      grouped in an array of nested structures.\r\n   <\/p>\r\n   <p>I have the images from a CT scan of my left ankle that I had taken after a wakeboarding accident a couple of summers ago.\r\n       We'll read the metadata into MATLAB using <a href=\"\"><tt>dicominfo<\/tt><\/a>.  Even though I likely trust any human reading this blog, I'm still going to anonymize the file to hide my personal information\r\n      like name, birthdate etc:\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\"><span style=\"color: #228B22\">% Anonymize<\/span>\r\nfn = <span style=\"color: #A020F0\">'CT000000'<\/span>;\r\nanonfn = [fn <span style=\"color: #A020F0\">'_anon'<\/span>];\r\ndicomanon(fn,anonfn);\r\n\r\n<span style=\"color: #228B22\">% Read in info:<\/span>\r\ninfo = dicominfo(anonfn);<\/pre><p>Now let's look at the simple display and the complex display using Thomas' <tt>fn_structdisp<\/tt>.  You'll be able to see how <tt>fn_structdisp<\/tt> unrolls the nested structures to reveal their contents.\r\n   <\/p>\r\n   <h3>Regular Display<a name=\"6\"><\/a><\/h3><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">disp(info)<\/pre><pre style=\"font-style:oblique\">                          Filename: 'C:\\Documents\\MATLAB\\potw\\StructDisp\\C...'\r\n                       FileModDate: '08-Apr-2015 22:35:13'\r\n                          FileSize: 559084\r\n                            Format: 'DICOM'\r\n                     FormatVersion: 3\r\n                             Width: 512\r\n                            Height: 512\r\n                          BitDepth: 16\r\n                         ColorType: 'grayscale'\r\n    FileMetaInformationGroupLength: 222\r\n        FileMetaInformationVersion: [2x1 uint8]\r\n           MediaStorageSOPClassUID: '1.2.840.10008.5.1.4.1.1.2'\r\n        MediaStorageSOPInstanceUID: '1.3.6.1.4.1.9590.100.1.2.515513049128...'\r\n                 TransferSyntaxUID: '1.2.840.10008.1.2.1'\r\n            ImplementationClassUID: '1.3.6.1.4.1.9590.100.1.3.100.7.1'\r\n         ImplementationVersionName: 'MATLAB IPT 7.1'\r\n      SourceApplicationEntityTitle: 'DCF'\r\n              SpecificCharacterSet: 'ISO_IR 100'\r\n                         ImageType: 'DERIVED\\SECONDARY\\OTHER\\CSA MPR THICK...'\r\n                       SOPClassUID: '1.2.840.10008.5.1.4.1.1.2'\r\n                    SOPInstanceUID: '1.3.6.1.4.1.9590.100.1.2.515513049128...'\r\n                         StudyDate: '20131007'\r\n                        SeriesDate: '20131007'\r\n                   AcquisitionDate: '20131007'\r\n                       ContentDate: '20131007'\r\n                         StudyTime: '184618.640000'\r\n                        SeriesTime: '184046.156000'\r\n                   AcquisitionTime: '184905.956783'\r\n                       ContentTime: '184046.171000'\r\n                   AccessionNumber: ''\r\n                          Modality: 'CT'\r\n                      Manufacturer: 'SIEMENS'\r\n                   InstitutionName: ''\r\n            ReferringPhysicianName: [1x1 struct]\r\n             ManufacturerModelName: 'Sensation 64'\r\n           ReferencedImageSequence: [1x1 struct]\r\n                       PatientName: [1x1 struct]\r\n                         PatientID: ''\r\n                  PatientBirthDate: ''\r\n                        PatientSex: ''\r\n            PatientIdentityRemoved: 'YES'\r\n            DeidentificationMethod: 'DICOMANON (rev R2010a) - PS 3.15-2008...'\r\n                  BodyPartExamined: 'EXTREMITY'\r\n                    SliceThickness: 2\r\n                               KVP: 120\r\n                   SoftwareVersion: 'syngo CT 2009E'\r\n          DistanceSourceToDetector: 1040\r\n           DistanceSourceToPatient: 570\r\n                GantryDetectorTilt: 0\r\n                       TableHeight: 179\r\n                 RotationDirection: 'CW'\r\n                        FilterType: '0'\r\n                    GeneratorPower: 10\r\n                         FocalSpot: 1.2000\r\n             DateOfLastCalibration: '20131007'\r\n             TimeOfLastCalibration: '061322.000000'\r\n                 ConvolutionKernel: 'B60s'\r\n                   PatientPosition: 'FFS'\r\n                  StudyInstanceUID: '1.3.6.1.4.1.9590.100.1.2.328077616812...'\r\n                 SeriesInstanceUID: '1.3.6.1.4.1.9590.100.1.2.237595359611...'\r\n                           StudyID: ''\r\n                      SeriesNumber: 505\r\n                 AcquisitionNumber: 3\r\n                    InstanceNumber: 1\r\n              ImagePositionPatient: [3x1 double]\r\n           ImageOrientationPatient: [6x1 double]\r\n               FrameOfReferenceUID: '1.3.6.1.4.1.9590.100.1.2.396775851196...'\r\n        PositionReferenceIndicator: ''\r\n                   SamplesPerPixel: 1\r\n         PhotometricInterpretation: 'MONOCHROME2'\r\n                              Rows: 512\r\n                           Columns: 512\r\n                      PixelSpacing: [2x1 double]\r\n                     BitsAllocated: 16\r\n                        BitsStored: 16\r\n                           HighBit: 15\r\n               PixelRepresentation: 0\r\n           SmallestImagePixelValue: 0\r\n            LargestImagePixelValue: 2802\r\n                      WindowCenter: 240\r\n                       WindowWidth: 1200\r\n                  RescaleIntercept: -1024\r\n                      RescaleSlope: 1\r\n      WindowCenterWidthExplanation: 'WINDOW1\\WINDOW2'\r\n             LossyImageCompression: '00'\r\n               RequestingPhysician: [1x1 struct]\r\n     RequestedProcedureDescription: 'CT LOWER EXTREMITY C-'\r\n                     OverlayRows_0: 512\r\n                  OverlayColumns_0: 512\r\n         NumberOfFramesInOverlay_0: 1\r\n              OverlayDescription_0: 'Siemens MedCom Object Graphics'\r\n                     OverlayType_0: 'G'\r\n                   OverlayOrigin_0: [2x1 int16]\r\n                ImageFrameOrigin_0: 1\r\n            OverlayBitsAllocated_0: 1\r\n              OverlayBitPosition_0: 0\r\n                     OverlayData_0: [512x512 logical]\r\n<\/pre><h3>fn_structdisp Display<a name=\"7\"><\/a><\/h3><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">fn_structdisp(info);<\/pre><pre style=\"font-style:oblique\">info:\r\n                          Filename: 'C:\\Documents\\MATLAB\\potw\\StructDisp\\C...'\r\n                       FileModDate: '08-Apr-2015 22:35:13'\r\n                          FileSize: 559084\r\n                            Format: 'DICOM'\r\n                     FormatVersion: 3\r\n                             Width: 512\r\n                            Height: 512\r\n                          BitDepth: 16\r\n                         ColorType: 'grayscale'\r\n    FileMetaInformationGroupLength: 222\r\n        FileMetaInformationVersion: [2x1 uint8]\r\n           MediaStorageSOPClassUID: '1.2.840.10008.5.1.4.1.1.2'\r\n        MediaStorageSOPInstanceUID: '1.3.6.1.4.1.9590.100.1.2.515513049128...'\r\n                 TransferSyntaxUID: '1.2.840.10008.1.2.1'\r\n            ImplementationClassUID: '1.3.6.1.4.1.9590.100.1.3.100.7.1'\r\n         ImplementationVersionName: 'MATLAB IPT 7.1'\r\n      SourceApplicationEntityTitle: 'DCF'\r\n              SpecificCharacterSet: 'ISO_IR 100'\r\n                         ImageType: 'DERIVED\\SECONDARY\\OTHER\\CSA MPR THICK...'\r\n                       SOPClassUID: '1.2.840.10008.5.1.4.1.1.2'\r\n                    SOPInstanceUID: '1.3.6.1.4.1.9590.100.1.2.515513049128...'\r\n                         StudyDate: '20131007'\r\n                        SeriesDate: '20131007'\r\n                   AcquisitionDate: '20131007'\r\n                       ContentDate: '20131007'\r\n                         StudyTime: '184618.640000'\r\n                        SeriesTime: '184046.156000'\r\n                   AcquisitionTime: '184905.956783'\r\n                       ContentTime: '184046.171000'\r\n                   AccessionNumber: ''\r\n                          Modality: 'CT'\r\n                      Manufacturer: 'SIEMENS'\r\n                   InstitutionName: ''\r\n            ReferringPhysicianName: [1x1 struct]\r\n             ManufacturerModelName: 'Sensation 64'\r\n           ReferencedImageSequence: [1x1 struct]\r\n                       PatientName: [1x1 struct]\r\n                         PatientID: ''\r\n                  PatientBirthDate: ''\r\n                        PatientSex: ''\r\n            PatientIdentityRemoved: 'YES'\r\n            DeidentificationMethod: 'DICOMANON (rev R2010a) - PS 3.15-2008...'\r\n                  BodyPartExamined: 'EXTREMITY'\r\n                    SliceThickness: 2\r\n                               KVP: 120\r\n                   SoftwareVersion: 'syngo CT 2009E'\r\n          DistanceSourceToDetector: 1040\r\n           DistanceSourceToPatient: 570\r\n                GantryDetectorTilt: 0\r\n                       TableHeight: 179\r\n                 RotationDirection: 'CW'\r\n                        FilterType: '0'\r\n                    GeneratorPower: 10\r\n                         FocalSpot: 1.2000\r\n             DateOfLastCalibration: '20131007'\r\n             TimeOfLastCalibration: '061322.000000'\r\n                 ConvolutionKernel: 'B60s'\r\n                   PatientPosition: 'FFS'\r\n                  StudyInstanceUID: '1.3.6.1.4.1.9590.100.1.2.328077616812...'\r\n                 SeriesInstanceUID: '1.3.6.1.4.1.9590.100.1.2.237595359611...'\r\n                           StudyID: ''\r\n                      SeriesNumber: 505\r\n                 AcquisitionNumber: 3\r\n                    InstanceNumber: 1\r\n              ImagePositionPatient: [3x1 double]\r\n           ImageOrientationPatient: [6x1 double]\r\n               FrameOfReferenceUID: '1.3.6.1.4.1.9590.100.1.2.396775851196...'\r\n        PositionReferenceIndicator: ''\r\n                   SamplesPerPixel: 1\r\n         PhotometricInterpretation: 'MONOCHROME2'\r\n                              Rows: 512\r\n                           Columns: 512\r\n                      PixelSpacing: [2x1 double]\r\n                     BitsAllocated: 16\r\n                        BitsStored: 16\r\n                           HighBit: 15\r\n               PixelRepresentation: 0\r\n           SmallestImagePixelValue: 0\r\n            LargestImagePixelValue: 2802\r\n                      WindowCenter: 240\r\n                       WindowWidth: 1200\r\n                  RescaleIntercept: -1024\r\n                      RescaleSlope: 1\r\n      WindowCenterWidthExplanation: 'WINDOW1\\WINDOW2'\r\n             LossyImageCompression: '00'\r\n               RequestingPhysician: [1x1 struct]\r\n     RequestedProcedureDescription: 'CT LOWER EXTREMITY C-'\r\n                     OverlayRows_0: 512\r\n                  OverlayColumns_0: 512\r\n         NumberOfFramesInOverlay_0: 1\r\n              OverlayDescription_0: 'Siemens MedCom Object Graphics'\r\n                     OverlayType_0: 'G'\r\n                   OverlayOrigin_0: [2x1 int16]\r\n                ImageFrameOrigin_0: 1\r\n            OverlayBitsAllocated_0: 1\r\n              OverlayBitPosition_0: 0\r\n                     OverlayData_0: [512x512 logical]\r\ninfo.FileSize:\r\n      559084\r\ninfo.Format:\r\nDICOM\r\ninfo.FormatVersion:\r\n     3\r\ninfo.Width:\r\n    512\r\ninfo.Height:\r\n    512\r\ninfo.BitDepth:\r\n     16\r\ninfo.ColorType:\r\ngrayscale\r\ninfo.FileMetaInformationGroupLength:\r\n         222\r\ninfo.FileMetaInformationVersion:\r\n    0\r\n    1\r\ninfo.SourceApplicationEntityTitle:\r\nDCF\r\ninfo.SpecificCharacterSet:\r\nISO_IR 100\r\ninfo.StudyDate:\r\n20131007\r\ninfo.SeriesDate:\r\n20131007\r\ninfo.AcquisitionDate:\r\n20131007\r\ninfo.ContentDate:\r\n20131007\r\ninfo.AccessionNumber:\r\ninfo.Modality:\r\nCT\r\ninfo.Manufacturer:\r\nSIEMENS\r\ninfo.InstitutionName:\r\ninfo.ReferringPhysicianName:\r\n    FamilyName: ''\r\n     GivenName: ''\r\n    MiddleName: ''\r\n    NamePrefix: ''\r\n    NameSuffix: ''\r\ninfo.ReferringPhysicianName.FamilyName:\r\ninfo.ReferringPhysicianName.GivenName:\r\ninfo.ReferringPhysicianName.MiddleName:\r\ninfo.ReferringPhysicianName.NamePrefix:\r\ninfo.ReferringPhysicianName.NameSuffix:\r\ninfo.ReferencedImageSequence:\r\n    Item_1: [1x1 struct]\r\ninfo.ReferencedImageSequence.Item_1:\r\n       ReferencedSOPClassUID: '1.2.840.10008.5.1.4.1.1.2'\r\n    ReferencedSOPInstanceUID: '1.3.12.2.1107.5.99.2.9567.30000013100710203...'\r\ninfo.PatientName:\r\n    FamilyName: ''\r\n     GivenName: ''\r\n    MiddleName: ''\r\n    NamePrefix: ''\r\n    NameSuffix: ''\r\ninfo.PatientName.FamilyName:\r\ninfo.PatientName.GivenName:\r\ninfo.PatientName.MiddleName:\r\ninfo.PatientName.NamePrefix:\r\ninfo.PatientName.NameSuffix:\r\ninfo.PatientID:\r\ninfo.PatientBirthDate:\r\ninfo.PatientSex:\r\ninfo.PatientIdentityRemoved:\r\nYES\r\ninfo.BodyPartExamined:\r\nEXTREMITY\r\ninfo.SliceThickness:\r\n     2\r\ninfo.KVP:\r\n   120\r\ninfo.DistanceSourceToDetector:\r\n        1040\r\ninfo.DistanceSourceToPatient:\r\n   570\r\ninfo.GantryDetectorTilt:\r\n     0\r\ninfo.TableHeight:\r\n   179\r\ninfo.RotationDirection:\r\nCW\r\ninfo.FilterType:\r\n0\r\ninfo.GeneratorPower:\r\n    10\r\ninfo.FocalSpot:\r\n    1.2000\r\ninfo.DateOfLastCalibration:\r\n20131007\r\ninfo.ConvolutionKernel:\r\nB60s\r\ninfo.PatientPosition:\r\nFFS\r\ninfo.StudyID:\r\ninfo.SeriesNumber:\r\n   505\r\ninfo.AcquisitionNumber:\r\n     3\r\ninfo.InstanceNumber:\r\n     1\r\ninfo.ImagePositionPatient:\r\n   -2.3311\r\n -228.0754\r\n  222.8133\r\ninfo.ImageOrientationPatient:\r\n    1.0000\r\n   -0.0000\r\n    0.0000\r\n    0.0000\r\n    0.0572\r\n   -0.9984\r\ninfo.PositionReferenceIndicator:\r\ninfo.SamplesPerPixel:\r\n      1\r\ninfo.Rows:\r\n    512\r\ninfo.Columns:\r\n    512\r\ninfo.PixelSpacing:\r\n    0.3379\r\n    0.3379\r\ninfo.BitsAllocated:\r\n     16\r\ninfo.BitsStored:\r\n     16\r\ninfo.HighBit:\r\n     15\r\ninfo.PixelRepresentation:\r\n      0\r\ninfo.SmallestImagePixelValue:\r\n      0\r\ninfo.LargestImagePixelValue:\r\n   2802\r\ninfo.WindowCenter:\r\n   240\r\ninfo.WindowWidth:\r\n        1200\r\ninfo.RescaleIntercept:\r\n       -1024\r\ninfo.RescaleSlope:\r\n     1\r\ninfo.LossyImageCompression:\r\n00\r\ninfo.RequestingPhysician:\r\n    FamilyName: 'TARQUINIO'\r\n     GivenName: 'THOM A.'\r\ninfo.RequestingPhysician.FamilyName:\r\nTARQUINIO\r\ninfo.RequestingPhysician.GivenName:\r\nTHOM A.\r\ninfo.OverlayRows_0:\r\n    512\r\ninfo.OverlayColumns_0:\r\n    512\r\ninfo.NumberOfFramesInOverlay_0:\r\n     1\r\ninfo.OverlayType_0:\r\nG\r\ninfo.OverlayOrigin_0:\r\n      1\r\n      1\r\ninfo.ImageFrameOrigin_0:\r\n      1\r\ninfo.OverlayBitsAllocated_0:\r\n      1\r\ninfo.OverlayBitPosition_0:\r\n      0\r\n<\/pre><p>And if you're curious what a CT scan of a really bad looking ankle looks like, here's a downsized animated gif created from\r\n      the full DICOM stack.\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainstructdisp\/SE000007_sm.gif\"> <\/p>\r\n   <h3>Comments<a name=\"9\"><\/a><\/h3>\r\n   <p>Give it a try and let us know what you think <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=5938#respond\">here<\/a> or leave a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/13831-structure-display#comments\">comment<\/a> for Thomas.\r\n   <\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_a1f4b8055dc74e5a8d487614c7487283() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='a1f4b8055dc74e5a8d487614c7487283 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' a1f4b8055dc74e5a8d487614c7487283';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        author = 'Sean de Wolski';\r\n        copyright = 'Copyright 2015 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n      \r\n      d.title = title + ' (MATLAB code)';\r\n      d.close();\r\n      }   \r\n      \r\n-->\r\n<\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_a1f4b8055dc74e5a8d487614c7487283()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n            the MATLAB code \r\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2015a<br><\/p>\r\n<\/div>\r\n<!--\r\na1f4b8055dc74e5a8d487614c7487283 ##### SOURCE BEGIN #####\r\n%% Structure Display\r\n%\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3208495 Sean>'s pick this week is\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/13831-structure-display Structure Display> by\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/898621 Thomas Deneux>.\r\n% \r\n\r\n%% Structures in MATLAB\r\n% A structure in MATLAB is a container for heterogenous data that you\r\n% reference by a name.  Let's take a look at a simple structure: we\r\n% will reference two fields of _S_ named _A_ and _B_ (I don't win too many\r\n% awards for creativity!).\r\n\r\nS.A = 'Hello World';\r\nS.B = pi;\r\ndisp(S)\r\n\r\n%%\r\n% This level of display is sufficient for a simple structure.  But what\r\n% about a more complex structure with possibly nested structures inside of\r\n% it?\r\n\r\nS.C = S; % insert S into one field of S, structure inception?\r\ndisp(S)\r\n\r\n%%\r\n% The built in display of the structure shows the high-level summary of the\r\n% fields it contains, not the detailed version which could be complex.\r\n% Sometimes this additional information is useful, especially for debugging.  \r\n%\r\n% Here's the display with |fn_structdisp|\r\n\r\nfn_structdisp(S);\r\n\r\n%% Metadata\r\n% One of the places this type of display is really useful is when looking\r\n% at metadata for files where the meta data can be logically grouped in an\r\n% array of nested structures.\r\n%\r\n% I have the images from a CT scan of my left ankle that I had taken after\r\n% a wakeboarding accident a couple of summers ago.  We'll read the metadata\r\n% into MATLAB using\r\n% <\r\n% |dicominfo|>.  Even though I likely trust any human reading this blog,\r\n% I'm still going to anonymize the file to hide my personal information\r\n% like name, birthdate etc:\r\n\r\n% Anonymize\r\nfn = 'CT000000';\r\nanonfn = [fn '_anon'];\r\ndicomanon(fn,anonfn);\r\n\r\n% Read in info:\r\ninfo = dicominfo(anonfn);\r\n\r\n%%\r\n% Now let's look at the simple display and the complex display using\r\n% Thomas' |fn_structdisp|.  You'll be able to see how |fn_structdisp|\r\n% unrolls the nested structures to reveal their contents.\r\n%\r\n\r\n%% Regular Display\r\ndisp(info)\r\n\r\n%% |fn_structdisp| Display\r\nfn_structdisp(info);\r\n\r\n%%\r\n% And if you're curious what a CT scan of a really bad looking ankle looks\r\n% like, here's a downsized animated gif created from the full DICOM stack.\r\n%\r\n% <<SE000007_sm.gif>>\r\n% \r\n\r\n\r\n%% Comments\r\n% \r\n% Give it a try and let us know what you think\r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=5938#respond here> or leave a\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/13831-structure-display#comments\r\n% comment> for Thomas.\r\n%\r\n \r\n\r\n##### SOURCE END ##### a1f4b8055dc74e5a8d487614c7487283\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainstructdisp\/SE000007_sm.gif\" onError=\"this.style.display ='none';\" \/><\/div><p>\r\n   \r\n      Sean's pick this week is Structure Display by Thomas Deneux.\r\n      \r\n   \r\n   Contents\r\n   \r\n      \r\n         Structures... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2015\/04\/10\/structure-display\/\">read more >><\/a><\/p>","protected":false},"author":87,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/5938"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/87"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=5938"}],"version-history":[{"count":2,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/5938\/revisions"}],"predecessor-version":[{"id":5940,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/5938\/revisions\/5940"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=5938"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=5938"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=5938"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}