コード例 #1
0
ファイル: imageHandling.py プロジェクト: KailongPeng/rt-cloud
def getDicomFileName(cfg, scanNum, fileNum):
    """
    This function takes in different variables (which are both specific to the specific
    scan and the general setup for the entire experiment) to produce the full filename
    for the dicom file of interest.

    Used externally.
    """
    if scanNum < 0:
        raise ValidationError(
            "ScanNumber not supplied or invalid {}".format(scanNum))

    # the naming pattern is provided in the toml file
    if cfg.dicomNamePattern is None:
        raise InvocationError("Missing config settings dicomNamePattern")

    if '{TR' in cfg.dicomNamePattern:
        fileName = cfg.dicomNamePattern.format(SCAN=scanNum, TR=fileNum)
    else:
        scanNumStr = str(scanNum).zfill(2)
        fileNumStr = str(fileNum).zfill(3)
        fileName = cfg.dicomNamePattern.format(scanNumStr, fileNumStr)
    fullFileName = os.path.join(cfg.dicomDir, fileName)

    return fullFileName
コード例 #2
0
ファイル: amygActivation.py プロジェクト: spolcyn/rt-cloud
def getDicomFileName(cfg, scanNum, fileNum):
    if scanNum < 0:
        raise ValidationError(
            "ScanNumber not supplied of invalid {}".format(scanNum))
    scanNumStr = str(scanNum).zfill(2)
    fileNumStr = str(fileNum).zfill(3)
    if cfg.dicomNamePattern is None:
        raise InvocationError("Missing config settings dicomNamePattern")
    fileName = cfg.dicomNamePattern.format(scanNumStr, fileNumStr)
    fullFileName = os.path.join(cfg.dicomDir, fileName)
    return fullFileName
コード例 #3
0
    def initScannerStream(self,
                          imgDir: str,
                          filePattern: str,
                          minFileSize: int,
                          demoStep: int = 0) -> int:
        """
        Initialize a data stream context with image directory and filepattern.
        Once the stream is initialized call getImageData() to retrieve image data.
        NOTE: currently only one stream at a time is supported.

        Args:
            imgDir: the directory where the images are or will be written from the MRI scanner.
            filePattern: a pattern of the image file names that has a TR tag which will be used
                to index the images, for example 'scan01_{TR:03d}.dcm'. In this example a call to
                getImageData(imgIndex=6) would look for dicom file 'scan01_006.dcm'.

        Returns:
            streamId: An identifier used when calling getImageData()
        """
        self._checkAllowedDirs(imgDir)
        self._checkAllowedFileTypes(filePattern)

        # check that filePattern has {TR} in it
        if not re.match(r'.*{TR.*', filePattern):
            raise InvocationError(
                r"initScannerStream filePattern must have a {TR} pattern")
        self.currentStreamId = self.currentStreamId + 1
        self.streamInfo = StructDict({
            'streamId': self.currentStreamId,
            'type': 'scanner',
            'imgDir': imgDir,
            'filePattern': filePattern,
            'minFileSize': minFileSize,
            'demoStep': demoStep,
            'imgIndex': 0,
        })
        _, file_ext = os.path.splitext(filePattern)
        self.initWatch(imgDir, '*' + file_ext, minFileSize, demoStep)
        return self.currentStreamId
コード例 #4
0
        action='store_true',
        help='user remote services for both data and subject interface')
    argParser.add_argument(
        '--port',
        default=8888,
        type=int,
        help='Network port that the projectServer will listen for requests on')
    argParser.add_argument('--test',
                           '-t',
                           default=False,
                           action='store_true',
                           help='start webServer in test mode, unsecure')
    args = argParser.parse_args()

    if args.projectName is None:
        raise InvocationError('Must specify project name using -p parameter')
    if args.projectDir is None:
        args.projectDir = os.path.join(rootPath, 'projects', args.projectName)
    if args.config is None:
        args.config = os.path.join(args.projectDir,
                                   f'conf/{args.projectName}.toml')
    if args.mainScript is None:
        args.mainScript = os.path.join(args.projectDir,
                                       f'{args.projectName}.py')
    if args.initScript is None:
        args.initScript = os.path.join(args.projectDir, 'initialize.py')
    if args.finalizeScript is None:
        args.finalizeScript = os.path.join(args.projectDir, 'finalize.py')
    if args.remote is True:
        args.dataRemote = True
        args.subjectRemote = True