Skip to content

Commit

Permalink
Minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelzwiers committed Aug 15, 2024
1 parent a9f4d00 commit d709c6a
Showing 1 changed file with 16 additions and 21 deletions.
37 changes: 16 additions & 21 deletions bidscoin/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@


class DataSource:
def __init__(self, provenance: Union[str, Path]='', plugins: Dict[str, Plugin]=None, dataformat: str='', datatype: str='', subprefix: str='', sesprefix: str=''):
"""
A source data type (e.g. DICOM or PAR) that can be converted to BIDS by the plugins
:param provenance: The full path of a representative file for this data source
:param plugins: The plugins that are used to interact with the source data type. Uses bidsmap['Options']['plugins'] format
:param dataformat: The dataformat name in the bidsmap, e.g. DICOM or PAR
:param datatype: The intended BIDS data type of the data source TODO: move to a separate BidsTarget/Mapping class
:param subprefix: The subprefix used in the sourcefolder
:param sesprefix: The sesprefix used in the sourcefolder
"""
"""
A source data type (e.g. DICOM or PAR) that can be converted to BIDS by the plugins
:param provenance: The full path of a representative file for this data source
:param plugins: The plugins that are used to interact with the source data type. Uses bidsmap['Options']['plugins'] format
:param dataformat: The dataformat name in the bidsmap, e.g. DICOM or PAR
:param datatype: The intended BIDS data type of the data source TODO: move to a separate BidsTarget/Mapping class
:param subprefix: The subprefix used in the sourcefolder
:param sesprefix: The sesprefix used in the sourcefolder
"""

def __init__(self, provenance: Union[str, Path]='', plugins: Dict[str, Plugin]=None, dataformat: str='', datatype: str='', subprefix: str='', sesprefix: str=''):
self.path: Path = Path(provenance)
self.datatype: str = datatype
self.dataformat: str = dataformat
Expand Down Expand Up @@ -546,8 +546,7 @@ def parse_x_protocol(pattern: str, dicomfile: Path) -> str:


# Profiling shows this is currently the most expensive function, therefore the (primitive but effective) _DICOMDICT_CACHE optimization
_DICOMDICT_CACHE = None
_DICOMFILE_CACHE = None
_DICOMDICT_CACHE = _DICOMFILE_CACHE = None
@lru_cache(maxsize=65536)
def get_dicomfield(tagname: str, dicomfile: Path) -> Union[str, int]:
"""
Expand Down Expand Up @@ -671,8 +670,7 @@ def get_dicomfield(tagname: str, dicomfile: Path) -> Union[str, int]:


# Profiling shows this is currently the most expensive function, therefore the (primitive but effective) cache optimization
_TWIXHDR_CACHE = None
_TWIXFILE_CACHE = None
_TWIXHDR_CACHE = _TWIXFILE_CACHE = None
@lru_cache(maxsize=65536)
def get_twixfield(tagname: str, twixfile: Path, mraid: int=2) -> Union[str, int]:
"""
Expand Down Expand Up @@ -742,8 +740,7 @@ def iterget(item, key):


# Profiling shows this is currently the most expensive function, therefore the (primitive but effective) _PARDICT_CACHE optimization
_PARDICT_CACHE = None
_PARFILE_CACHE = None
_PARDICT_CACHE = _PARFILE_CACHE = None
@lru_cache(maxsize=65536)
def get_parfield(tagname: str, parfile: Path) -> Union[str, int]:
"""
Expand Down Expand Up @@ -796,8 +793,7 @@ def get_parfield(tagname: str, parfile: Path) -> Union[str, int]:


# Profiling shows this is currently the most expensive function, therefore the (primitive but effective) cache optimization
_SPARHDR_CACHE = None
_SPARFILE_CACHE = None
_SPARHDR_CACHE = _SPARFILE_CACHE = None
@lru_cache(maxsize=65536)
def get_sparfield(tagname: str, sparfile: Path) -> Union[str, int]:
"""
Expand Down Expand Up @@ -847,8 +843,7 @@ def get_sparfield(tagname: str, sparfile: Path) -> Union[str, int]:


# Profiling shows this is currently the most expensive function, therefore the (primitive but effective) cache optimization
_P7HDR_CACHE = None
_P7FILE_CACHE = None
_P7HDR_CACHE = _P7FILE_CACHE = None
@lru_cache(maxsize=65536)
def get_p7field(tagname: str, p7file: Path) -> Union[str, int]:
"""
Expand Down

0 comments on commit d709c6a

Please sign in to comment.