Exemplo n.º 1
0
    def stamp(self):
        def get_associated_files(filepath):
            result = []
            if '.nii' in filepath.suffixes:
                bval = filepath.with_suffix('.bval', depth=2)
                bvec = filepath.with_suffix('.bvec', depth=2)
                result.extend([f for f in [bval, bvec] if f.exists()])
            if '.nhdr' in filepath.suffixes:
                rawgz = filepath.with_suffix('.raw.gz')
                raw = filepath.with_suffix('.raw')
                if raw.exists():
                    raise Exception(
                        "'{}' has an unzipped raw file, zip the nhdr first(e.g. unu save -e gzip -f nrrd -i nhdr -o nhdr) "
                    )
                if rawgz.exists():
                    result.append(rawgz)
            return result

        if self.output().is_dir():
            return dirhash(self.output())

        allfiles = get_associated_files(self.output()) + [self.output()]
        if len(allfiles) > 1:
            return reduce_hash([filehash(f) for f in allfiles], 'md5')
        return filehash(self.output())
Exemplo n.º 2
0
 def stamp(self):
     return dirhash(self.output(), included_extensions=['.vtk'])