Skip to content

Commit

Permalink
changed where the scan type escape occurs
Browse files Browse the repository at this point in the history
  • Loading branch information
tclose committed Mar 14, 2024
1 parent da34b2f commit 0121350
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions xnat_ingest/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,16 @@
logger = logging.getLogger("xnat-ingest")


def scan_type_converter(scan_type: str) -> str:
"Ensure there aren't any special characters that aren't valid file/dir paths"
return re.sub(r"[\"\*\/\:\<\>\?\\\|\+\,\.\;\=\[\]]+", "", scan_type)


@attrs.define
class ImagingScan:
id: str
type: str
resources: ty.Dict[str, FileSet]
type: str = attrs.field(converter=scan_type_converter)
resources: ty.Dict[str, FileSet] = attrs.field()

def __contains__(self, resource_name):
return resource_name in self.resources
Expand Down Expand Up @@ -531,10 +536,7 @@ def stage(
staged_resources = {}
for resource_name, fileset in scan.resources.items():
# Ensure scan type is a valid directory name
scan_type = re.sub(
r"[\"\*\/\:\<\>\?\\\|\+\,\.\;\=\[\]]+", "", scan.type
)
scan_dir = session_dir / f"{scan.id}-{scan_type}" / resource_name
scan_dir = session_dir / f"{scan.id}-{scan.type}" / resource_name
scan_dir.mkdir(parents=True, exist_ok=True)
if isinstance(fileset, DicomSeries):
staged_dicom_paths = []
Expand Down

0 comments on commit 0121350

Please sign in to comment.