bids-matlab-tools icon indicating copy to clipboard operation
bids-matlab-tools copied to clipboard

Never ending loop in bids_importjson

Open crisglav opened this issue 1 year ago • 2 comments

Hi, when I run pop_importbids, it gets in a never ending loop in line 468, when calling bids_importjson.

I think it has to do with this part of the code.

https://github.com/sccn/EEG-BIDS/blob/bf6001cce2cc64cc28124cf15f185b9314402eb5/bids_importjson.m#L40C4-L55C12

Best, Cristina

crisglav avatar May 21 '24 15:05 crisglav

@dungscout96 can you have a look. This is code you recently added I think.

arnodelorme avatar May 21 '24 17:05 arnodelorme

specifically this part: % if ~isTopLevel(curFile) % upperFile = fullfile(fileparts(fileparts(curFile)), ['*' ext]); % % resolve wildcard if applicable % upperFileDir = dir(upperFile); % if ~isempty(upperFileDir) % for u=1:numel(upperFileDir) % % check using rule 2.b and 2.c % % of https://bids-specification.readthedocs.io/en/stable/common-principles.html#the-inheritance-principle % upperFileName = upperFileDir(u).name; % upperFileName_parts = strsplit(upperFileName, '_'); % if contains(oriFile, upperFileName_parts) % upperFile = fullfile(upperFileDir(u).folder, upperFileDir(u).name); % break % end % end % end % upperjsondata = bids_importjson(upperFile, ext, oriFile); %
% % mergeStructures credit: https://www.mathworks.com/matlabcentral/fileexchange/131718-mergestructures-merge-or-concatenate-nested-structures?s_tid=mwa_osa_a % curjsondata = mergeStructures(curjsondata, upperjsondata); % end

neuroLena avatar Jul 01 '24 12:07 neuroLena

Any update here? There appears to be a loop that endlessly looks for upper level .json files if there are none found

kacross avatar Aug 22 '24 16:08 kacross

This should have been fixed. Please pull the latest changes and let us know if this is still an issue for you. Closing this issue for now

dungscout96 avatar Aug 29 '24 16:08 dungscout96

The never ending loop was due to the lack of README.md file at the root. Now, we are also checking for datasetdescription.json which is mandatory (README.md is not)

arnodelorme avatar Aug 29 '24 16:08 arnodelorme