Skip to content

Commit

Permalink
bug fix for subs when rawdata not present
Browse files Browse the repository at this point in the history
  • Loading branch information
wiheto committed Feb 5, 2019
1 parent 6204b84 commit 212cae9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## V0.4.2

- Fixed a bug in load data of TenetoBIDS when loading networkmeasures from multiple subjects (error was thrown).
-

## V0.4.1

- More documentation
Expand Down
26 changes: 12 additions & 14 deletions teneto/classes/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,8 @@ def get_tags(self,tag,quiet=1):
self.get_pipeline_alternatives(quiet)
else:
if tag == 'sub':
tag_alternatives = [f.split('sub-')[1] for f in os.listdir(self.BIDS_dir + '/derivatives/' + self.pipeline)]
datapath = self.BIDS_dir + '/derivatives/' + self.pipeline + '/'
tag_alternatives = [f.split('sub-')[1] for f in os.listdir(datapath) if os.path.isdir(datapath + f)]
elif tag == 'ses':
tag_alternatives = []
for sub in self.bids_tags['sub']:
Expand Down Expand Up @@ -1595,9 +1596,6 @@ def load_data(self, datatype='tvc', tag=None, measure=''):
tag : str or list
any additional tag that must be in file name. After the tag there must either be a underscore or period (following bids).
timelocked : bool
Load timelocked data if true.
measure : str
retquired when datatype is temporalnetwork. A networkmeasure that should be loaded.
Expand Down Expand Up @@ -1633,16 +1631,16 @@ def load_data(self, datatype='tvc', tag=None, measure=''):
trialinfo_list.append(pd.DataFrame(filetags,index=[0]))
except pd.errors.EmptyDataError:
pass
# If group data and length of output is one, don't make it a list
if datatype == 'group' and len(data_list) == 1:
data_list = data_list[0]
if measure:
data_list = {measure: data_list}
setattr(self,datatype + '_data_', data_list)
if trialinfo_list:
out_trialinfo = pd.concat(trialinfo_list)
out_trialinfo.reset_index(inplace=True, drop=True)
setattr(self,datatype + '_trialinfo_', out_trialinfo)
# If group data and length of output is one, don't make it a list
if datatype == 'group' and len(data_list) == 1:
data_list = data_list[0]
if measure:
data_list = {measure: data_list}
setattr(self,datatype + '_data_', data_list)
if trialinfo_list:
out_trialinfo = pd.concat(trialinfo_list)
out_trialinfo.reset_index(inplace=True, drop=True)
setattr(self,datatype + '_trialinfo_', out_trialinfo)


# REMAKE BELOW BASED ON THE _events from BIDS
Expand Down

0 comments on commit 212cae9

Please sign in to comment.