Skip to content

Commit d669e96

Browse files
committed
verion 0.5.3
1 parent 73f13cc commit d669e96

File tree

4 files changed

+62
-21
lines changed

4 files changed

+62
-21
lines changed

CHANGELOG.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
# Changelog
22

3-
## Version 0.5.2 (In development)
3+
## Version 0.5.3
4+
5+
### Improvements
6+
Improved tenetobids loading of temporal network files (reshaped correctly).
7+
8+
Event files in tenetobids
9+
10+
get_aux_file new name of get_confound_files.
11+
12+
## Fixes
13+
Force order of columns for TemporalNetwork (fixes #73)
14+
15+
Fixing problems regarding documentation and testing
16+
17+
## Changes
18+
Changed numpy requirement to 1.20.1
19+
20+
21+
## Version 0.5.2
422

523
### 0.5.2 Improvements
624

@@ -10,7 +28,7 @@ Improved sidecar checking.
1028

1129
Added is_jsonable to utils.
1230

13-
~~Check_packages added (credit to @jolespin). Modified somewhat as importing to globals within wrapper was not working. This was accepted then removed.~~
31+
~~Check_packages added (credit to @jolespin). Modified somewhat as importing to globals within wrapper was not working. This was accepted to main branch then removed.~~
1432

1533
Session in TenetoBids now included, if present.
1634

teneto/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.5.2-dev-c"
1+
__version__ = "0.5.3"

teneto/classes/bids.py

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ def run(self, run_func, input_params, output_desc=None, output_pipeline_name=Non
170170
run_func, output_pipeline_name, self.exist_ok)
171171

172172
input_files = self.get_selected_files(run_func.split('.')[-1])
173+
173174
if not input_files:
174175
raise ValueError('No input files')
175176
if troubleshoot:
@@ -182,11 +183,12 @@ def run(self, run_func, input_params, output_desc=None, output_pipeline_name=Non
182183
for f in input_files:
183184
f_entities = f.get_entities()
184185
if get_confounds == 1:
185-
input_params['confounds'] = self.get_confounds(f)
186+
input_params['confounds'] = self.get_aux_file(f, filetype='confounds')
186187
data, sidecar = self.load_file(f)
187-
self.troubleshoot('Input file name', {'f': f,
188-
'f_entities': f_entities,
189-
'sidecar': sidecar})
188+
if troubleshoot:
189+
self.troubleshoot('Input file name', {'f': f,
190+
'f_entities': f_entities,
191+
'sidecar': sidecar})
190192
if 'sidecar' in dict(funcparams):
191193
input_params['sidecar'] = sidecar
192194
if data is None:
@@ -393,32 +395,39 @@ def update_bids_filter(self, filter_addons):
393395
"""
394396
self.bids_filter.update(filter_addons)
395397

396-
def get_confounds(self, bidsfile, confound_filters=None):
397-
"""Tries to automatically get the confounds file of an input file, and loads it
398+
def get_aux_file(self, bidsfile, filetype='confounds'):
399+
"""Tries to automatically get auxiliary data for input files, and loads it
398400
399401
Paramters
400402
==========
401403
bidsfile : BIDSDataFile or BIDSImageFile
402404
The BIDS file that the confound file is gong to be matched.
405+
filetype : string
406+
Can be confounds, events.
407+
Specified if you want to get the confound or events data.
403408
"""
404-
if confound_filters is None:
405-
confound_filters = {}
409+
if filetype == 'confounds':
410+
suffix = 'regressors'
411+
elif filetype == 'events':
412+
suffix = 'events'
413+
else:
414+
raise ValueError('unknown file type')
406415
# Get the entities of the filename
407416
file_entities = bidsfile.get_entities()
408417
# Ensure that the extension and suffix are correct
409-
file_entities['suffix'] = 'regressors'
418+
file_entities['suffix'] = suffix
410419
file_entities['extension'] = '.tsv'
411420
if 'desc' in file_entities:
412421
file_entities.pop('desc')
413-
confoundsfile = self.BIDSLayout.get(**file_entities)
414-
if len(confoundsfile) == 0:
415-
raise ValueError('Non confounds found')
416-
elif len(confoundsfile) > 1:
417-
raise ValueError('More than one confounds file found')
418-
# Load the confounds file
419-
confounds = load_tabular_file(
420-
confoundsfile[0].dirname + '/' + confoundsfile[0].filename, index_col=False)
421-
return confounds
422+
auxfile = self.BIDSLayout.get(**file_entities)
423+
if len(auxfile) == 0:
424+
raise ValueError('Non auxiliary file (type: ' + filetype + ') found')
425+
elif len(auxfile) > 1:
426+
raise ValueError('More than one auxiliary file (type: ' + filetype + ') found')
427+
# Load the aux file
428+
aux = load_tabular_file(
429+
auxfile[0].dirname + '/' + auxfile[0].filename, index_col=False)
430+
return aux
422431

423432
def load_data(self, bids_filter=None):
424433
"""Returns data, default is the input data.
@@ -484,3 +493,13 @@ def troubleshoot(self, stepname, status):
484493
print(status[step])
485494
print('++++++++')
486495
print('******** TROUBLESHOOT STEP: ' + stepname + ', end ********')
496+
497+
def load_events(self):
498+
"""
499+
Loads event data for selected files
500+
"""
501+
input_files = self.get_selected_files()
502+
events = {}
503+
for f in input_files:
504+
events[f.filename] = self.get_aux_file(f, filetype='events')
505+
return events
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
onset duration trial_type value
2+
1 2 stim-a 1
3+
3 2 stim-b 2
4+
4 3 stim-a 1

0 commit comments

Comments
 (0)