Ignore:
Timestamp:
Oct 4, 2017, 3:55:18 PM (7 years ago)
Author:
g7moreau
Message:
  • Remove property svn:executable
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/hdf5load_recursion.m

    • Property svn:executable deleted
    r947 r1013  
    1414function datastruct = hdf5load_recursive(datastruct,GroupHierarchy)
    1515
    16 % Load the datasets (the leafs of the tree):
    17 for i=[1:size(GroupHierarchy.Datasets,2)]
    18     data=hdf5read(GroupHierarchy.Datasets(i));
    19     switch class(data)
    20         case 'hdf5.h5string'
    21             try
    22                 if size(data,2)>1
    23                     buffer=data ;
    24                     data = {} ;
    25                     for j=1:size(buffer,2)
    26                         data{j}=buffer(j).Data;
    27                     end
    28                 else
    29                     data=data.Data;
    30                 end
    31             catch
    32             end
    33         case 'hdf5.h5array'
    34             try
    35                 if size(data,2)>1
    36                     buffer=data ;
    37                     data = {} ;
    38                     for j=1:size(buffer,2)
    39                         data{j}=buffer(j).Data;
    40                     end
    41                 else
    42                     data=data.Data;
    43                 end
    44             catch
    45             end
    46        
     16    % Load the datasets (the leafs of the tree):
     17    for i=[1:size(GroupHierarchy.Datasets,2)]
     18        data=hdf5read(GroupHierarchy.Datasets(i));
     19        switch class(data)
     20            case 'hdf5.h5string'
     21                try
     22                    if size(data,2)>1
     23                        buffer=data;
     24                        data = {};
     25                        for j=1:size(buffer,2)
     26                            data{j}=buffer(j).Data;
     27                        end
     28                    else
     29                        data=data.Data;
     30                    end
     31                catch
     32                end
     33            case 'hdf5.h5array'
     34                try
     35                    if size(data,2)>1
     36                        buffer=data;
     37                        data = {};
     38                        for j=1:size(buffer,2)
     39                       data{j}=buffer(j).Data;
     40                        end
     41                    else
     42                        data=data.Data;
     43                    end
     44                catch
     45                end
     46        end
     47        name=GroupHierarchy.Datasets(i).Name;
     48        name=strrep(name,'/','.');
     49        eval(['datastruct' name '= data ;'])
    4750    end
    48     name=GroupHierarchy.Datasets(i).Name;
    49     name=strrep(name,'/','.');
    50     eval(['datastruct' name '= data ;'])
     51    for i=[1:size(GroupHierarchy.Attributes,2)]
     52        data=hdf5read(GroupHierarchy.Attributes(i));
     53        switch class(data)
     54            case 'hdf5.h5string'
     55                try
     56                    if size(data,2)>1
     57                        buffer=data;
     58                        data = {};
     59                        for j=1:size(buffer,2)
     60                       data{j}=buffer(j).Data;
     61                        end
     62                    else
     63                        data=data.Data;
     64                    end
     65                catch
     66                end
     67            case 'hdf5.h5array'
     68                try
     69                    if size(data,2)>1
     70                        buffer=data;
     71                        data = {};
     72                        for j=1:size(buffer,2)
     73                       data{j}=buffer(j).Data;
     74                        end
     75                    else
     76                        data=data.Data;
     77                    end
     78                catch
     79                end
     80        end
     81        name=GroupHierarchy.Attributes(i).Name;
     82        name=strrep(name,'/','.');
     83        eval(['datastruct' name '= data ;'])
     84    end
     85
     86    % Then load the branches:
     87    % Create structures for the group and pass them on recursively:
     88    for i=[1:size(GroupHierarchy.Groups,2)]
     89        name=GroupHierarchy.Groups(i).Name;
     90        name=strrep(name,'/','.');
     91        eval(['datastruct' name '= struct ;']);
     92        datastruct = hdf5load_recursion(datastruct,GroupHierarchy.Groups(i));
     93    end
    5194end
    52 for i=[1:size(GroupHierarchy.Attributes,2)]
    53     data=hdf5read(GroupHierarchy.Attributes(i));
    54     switch class(data)
    55         case 'hdf5.h5string'
    56             try
    57                 if size(data,2)>1
    58                     buffer=data ;
    59                     data = {} ;
    60                     for j=1:size(buffer,2)
    61                         data{j}=buffer(j).Data;
    62                     end
    63                 else
    64                     data=data.Data;
    65                 end
    66             catch
    67             end
    68         case 'hdf5.h5array'
    69             try
    70                 if size(data,2)>1
    71                     buffer=data ;
    72                     data = {} ;
    73                     for j=1:size(buffer,2)
    74                         data{j}=buffer(j).Data;
    75                     end
    76                 else
    77                     data=data.Data;
    78                 end
    79             catch
    80         end
    81     end
    82     name=GroupHierarchy.Attributes(i).Name;
    83     name=strrep(name,'/','.');
    84     eval(['datastruct' name '= data ;'])
    85 end
    86 
    87 % Then load the branches:
    88 % Create structures for the group and pass them on recursively:
    89 for i=[1:size(GroupHierarchy.Groups,2)]
    90     name=GroupHierarchy.Groups(i).Name;
    91     name=strrep(name,'/','.');
    92     eval(['datastruct' name '= struct ;']);
    93     datastruct = hdf5load_recursion(datastruct,GroupHierarchy.Groups(i));
    94 end
    95 
Note: See TracChangeset for help on using the changeset viewer.