Skip to content

Commit

Permalink
Merge pull request #280 from NeurodataWithoutBorders/279-fix-ignorecache
Browse files Browse the repository at this point in the history
nwbRead now ignores .specloc and its target
  • Loading branch information
lawrence-mbf authored May 14, 2021
2 parents 96bbb7e + 8997b4d commit 8ddf90c
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions nwbRead.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,20 @@
'groups', {{}});
validateattributes(filename, {'char', 'string'}, {'scalartext', 'nonempty'});

if ~ignoreCache
specLocation = checkEmbeddedSpec(filename);
if ~isempty(specLocation)
Blacklist.groups{end+1} = specLocation;
end
specLocation = getEmbeddedSpec(filename);
if ~isempty(specLocation)
Blacklist.groups{end+1} = specLocation;
end

if ~ignoreCache && ~isempty(specLocation)
generateSpec(filename, h5info(filename, specLocation));
rehash(); % required if we want parseGroup to read the right files.
end

nwb = io.parseGroup(filename, h5info(filename), Blacklist);
end

function specLocation = checkEmbeddedSpec(filename)
function specLocation = getEmbeddedSpec(filename)
specLocation = '';
fid = H5F.open(filename);
try
Expand All @@ -41,24 +44,18 @@
referenceRawData = H5A.read(attributeId);
specLocation = H5R.get_name(attributeId, 'H5R_OBJECT', referenceRawData);
H5A.close(attributeId);
generateSpec(fid, h5info(filename, specLocation));
catch ME
if ~strcmp(ME.identifier, 'MATLAB:imagesci:hdf5lib:libraryError')
rethrow(ME);
end

attributeId = H5A.open(fid, 'nwb_version');
version = H5A.read(attributeId);
H5A.close(attributeId);

generateCore(version);
end % don't error if the attribute doesn't exist.
end
rehash(); % required if we want parseGroup to read the right files.

H5F.close(fid);
end

function generateSpec(fid, specinfo)
function generateSpec(filename, specinfo)
specNames = cell(size(specinfo.Groups));
fid = H5F.open(filename);
for i=1:length(specinfo.Groups)
location = specinfo.Groups(i).Groups(1);

Expand Down Expand Up @@ -88,6 +85,8 @@ function generateSpec(fid, specinfo)
Namespace = spec.generate(namespaceText, schemaMap);
specNames{i} = Namespace.name;
end
H5F.close(fid);
fid = [];

missingNames = cell(size(specNames));
for i = 1:length(specNames)
Expand Down

0 comments on commit 8ddf90c

Please sign in to comment.