Ejemplo n.º 1
0
 def from_path(cls, path, frequency='per_session', format=None,  # @ReservedAssignment @IgnorePep8
               **kwargs):
     if not os.path.exists(path):
         raise ArcanaUsageError(
             "Attempting to read Fileset from path '{}' but it "
             "does not exist".format(path))
     if os.path.isdir(path):
         within_exts = frozenset(
             split_extension(f)[1] for f in os.listdir(path)
             if not f.startswith('.'))
         if format is None:
             # Try to guess format
             try:
                 format = FileFormat.by_within_dir_exts(within_exts)  # @ReservedAssignment @IgnorePep8
             except ArcanaFileFormatNotRegisteredError:
                 # Fall back to general directory format
                 format = directory_format  # @ReservedAssignment
         name = os.path.basename(path)
     else:
         filename = os.path.basename(path)
         name, ext = split_extension(filename)
         if format is None:
             try:
                 format = FileFormat.by_ext(ext)  # @ReservedAssignment @IgnorePep8
             except ArcanaFileFormatNotRegisteredError as e:
                 raise ArcanaFileFormatNotRegisteredError(
                     str(e) + ", which is required to identify the "
                     "format of the fileset at '{}'".format(path))
     return cls(name, format, frequency=frequency,
                path=path, **kwargs)
Ejemplo n.º 2
0
Archivo: bids.py Proyecto: amrka/banana
 def __init__(
         self,
         path,
         type,
         subject_id,
         visit_id,
         repository,  # @ReservedAssignment @IgnorePep8
         modality=None,
         task=None,
         checksums=None):
     Fileset.__init__(self,
                      name=op.basename(path),
                      format=FileFormat.by_ext(split_extension(path)[1]),
                      frequency='per_session',
                      path=path,
                      subject_id=subject_id,
                      visit_id=visit_id,
                      repository=repository,
                      checksums=checksums)
     BaseBidsFileset.__init__(self, type, modality, task)