-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
177 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
function kwargs = map2kwargs(map) | ||
%containers.Map -> keyword args for types | ||
kwargs = cell(1, map.Count); | ||
mapkeys = keys(map); | ||
for i=1:length(mapkeys) | ||
k = mapkeys{i}; | ||
kwargs{(i*2)-1} = k; | ||
kwargs{i*2} = map(k); | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
function [parsed, refs] = parseDataset(filename, info, fullpath) | ||
%typed and untyped being container maps containing type and untyped datasets | ||
% the maps store information regarding information and stored data | ||
% NOTE, dataset name is in path format so we need to parse that out. | ||
refs = containers.Map; | ||
name = info.Name; | ||
|
||
%check if typed and parse attributes | ||
[attrargs, typename] = io.parseAttributes(info.Attributes); | ||
|
||
if isempty(typename) %a Group's properties | ||
parsed = containers.Map; | ||
afields = keys(attrargs); | ||
for j=1:length(afields) | ||
attr = afields{j}; | ||
parsed([name '_' attr]) = attrargs(attr); | ||
end | ||
data = h5read(filename, fullpath); | ||
if iscellstr(data) | ||
data = data{1}; | ||
elseif iscell(data) | ||
keyboard; | ||
end | ||
parsed(name) = data; | ||
return; | ||
end | ||
% given name, either a: | ||
% direct reference (ElectrodeTableRegion) | ||
% compound data w/ reference (ElectrodeTable) | ||
% All other cases do not exist in this current schema. | ||
props = attrargs; | ||
props('associated_nwbfile') = filename; | ||
|
||
fid = H5F.open(filename); | ||
did = H5D.open(fid, fullpath); | ||
data = H5D.read(did); %this way, references are not automatically resolved | ||
|
||
datatype = info.Datatype; | ||
if strcmp(datatype.Class, 'H5T_REFERENCE') | ||
reftype = datatype.Type; | ||
switch reftype | ||
case 'H5R_OBJECT' | ||
%TODO when included in schema | ||
case 'H5R_DATASET_REGION' | ||
sid = H5R.get_region(did, reftype, data); | ||
[start, finish] = H5S.get_select_bounds(sid); | ||
props('target') = H5R.get_name(did, reftype, data); | ||
props('region') = [start+1 finish]; | ||
H5S.close(sid); | ||
end | ||
elseif strcmp(datatype.Class, 'H5T_COMPOUND') | ||
t = table; | ||
compound = datatype.Type.Member; | ||
isref = logical(size(compound)); | ||
for j=1:length(compound) | ||
comp = compound(j); | ||
if strcmp(comp.Datatype.Class, 'H5T_REFERENCE') | ||
isref(j) = true; | ||
end | ||
end | ||
end | ||
kwargs = io.map2kwargs(props); | ||
parsed = eval([typename '(kwargs{:})']); | ||
|
||
H5D.close(did); | ||
H5F.close(fid); | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
function [parsed, links, refs] = parseGroup(filename, info) | ||
% NOTE, group name is in path format so we need to parse that out. | ||
% parsed is either a containers.Map containing properties mapped to values OR a | ||
% typed value | ||
links = []; | ||
refs = containers.Map; | ||
[~, root] = io.pathParts(info.Name); | ||
[props, typename] = io.parseAttributes(info.Attributes); | ||
|
||
%parse datasets | ||
for i=1:length(info.Datasets) | ||
ds_info = info.Datasets(i); | ||
fp = [info.Name '/' ds_info.Name]; | ||
[ds, dsrefs] = io.parseDataset(filename, ds_info, fp); | ||
props = [props; ds]; | ||
refs = [refs; dsrefs]; | ||
end | ||
|
||
%parse links if present | ||
for i=1:length(info.Links) | ||
links = [links io.parseLink(info.Links)]; | ||
end | ||
|
||
%parse subgroups | ||
for i=1:length(info.Groups) | ||
g_info = info.Groups(i); | ||
[~, gname] = io.pathParts(g_info.Name); | ||
[subg, glinks, grefs] = io.parseGroup(filename, g_info); | ||
props(gname) = subg; | ||
links = [links glinks]; | ||
refs = [refs; grefs]; | ||
end | ||
|
||
if isempty(typename) | ||
parsed = containers.Map; | ||
keyboard; | ||
else | ||
%construct as kwargs and instantiate object | ||
|
||
if isempty(root) | ||
%we are root | ||
parsed = types.core.NWBFile; | ||
return; | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
function link = parseLink(info) | ||
% just return a link | ||
link = []; | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
function s = cellPrettyPrint(val) | ||
s = ''; | ||
for i=1:length(val) | ||
s = [s ' ''' val{i} '''']; | ||
v = val{i}; | ||
[~, status] = str2num(v); | ||
if status | ||
wrapped_v = v; | ||
else | ||
wrapped_v = ['''' v '''']; | ||
end | ||
s = [s ' ' wrapped_v]; | ||
end | ||
s = ['{ ' strtrim(s) ' }']; | ||
end |
Oops, something went wrong.