Skip to content

Commit

Permalink
[ENH] A class to parse task data
Browse files Browse the repository at this point in the history
  • Loading branch information
bclenet committed Oct 4, 2023
1 parent e284b80 commit f9a3d3a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions narps_open/data/task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/python
# coding: utf-8

""" A mdoule to parse task data from NARPS for the narps_open package """

from os.path import join
from json import load

from narps_open.utils.configuration import Configuration
from narps_open.utils.singleton import SingletonMeta

class TaskInformation(dict, metaclass=SingletonMeta):
""" This class allows to access information about the task performed in NARPS """

def __init__(self):
super().__init__()

# Load information from the task-MGT_bold.json file
file_name = join(Configuration()['directories']['dataset'], 'task-MGT_bold.json')
self.update(load(file))

# Compute derived information
self['NumberOfSlices'] = len(self['SliceTiming'])
self['AcquisitionTime'] = self['RepetitionTime'] / self['NumberOfSlices']
self['TotalReadoutTime'] = self['NumberOfSlices'] * self['EffectiveEchoSpacing']

0 comments on commit f9a3d3a

Please sign in to comment.