예제 #1
0
    def test_initializeSession(self):
        """ test general_utils.initializeSession() """
        # loop over the different scan environments
        for scanEnv in ['GE', 'Philips', 'Siemens']:
            print('testing environment: ' + scanEnv)

            # set paths based on current test environment
            if scanEnv == 'GE':
                envDir = paths['GE_dir']
                funcDir = paths['GE_funcDir']
            elif scanEnv == 'Philips':
                envDir = paths['Philips_dir']
                funcDir = paths['Philips_funcDir']
            elif scanEnv == 'Siemens':
                envDir = paths['Siemens_dir']
                funcDir = paths['Siemens_funcDir']

            # update config file to match local paths
            configFile = join(envDir, 'scannerConfig.yaml')
            helper_tools.replace_scannerConfig_sessionDir(configFile, funcDir)

            general_utils.initializeSession(pynealScannerDir=envDir)

            # remove local paths from config file
            helper_tools.cleanConfigFile(configFile)

            print('Passed!')
예제 #2
0
    def test_initializeSession(self):
        """ test general_utils.initializeSession() """
        # loop over the different scan environments
        for scanEnv in ['GE', 'Philips', 'Siemens']:
            print('testing environment: ' + scanEnv)

            # set paths based on current test environment
            if scanEnv == 'GE':
                envDir = paths['GE_dir']
                funcDir = paths['GE_funcDir']
            elif scanEnv == 'Philips':
                envDir = paths['Philips_dir']
                funcDir = paths['Philips_funcDir']
            elif scanEnv == 'Siemens':
                envDir = paths['Siemens_dir']
                funcDir = paths['Siemens_funcDir']

            # update config file to match local paths
            configFile = join(envDir, 'scannerConfig.yaml')
            helper_tools.replace_scannerConfig_baseDir(configFile, funcDir)

            general_utils.initializeSession(pynealScannerDir=envDir)

            # remove local paths from config file
            helper_tools.cleanConfigFile(configFile)

            print('Passed!')
예제 #3
0
    def test_getSeries_Siemens(self):
        """ test getSeries.getSeries_Siemens """

        envDir = paths['Siemens_dir']
        funcDir = paths['Siemens_funcDir']

        # update config file to match local paths
        configFile = join(envDir, 'scannerConfig.yaml')
        helper_tools.replace_scannerConfig_baseDir(configFile, funcDir)

        # run initializeSettings to get the scannerDirs object
        scannerSettings, scannerDirs = general_utils.initializeSession(
            pynealScannerDir=envDir)

        ### run getSeries_Siemens
        import pyneal_scanner.getSeries as getSeries

        # module expects user to input 2 things: desired series, and output prefix.
        # We have to mock the input for automatic testing, but can only mock one
        # input (at least as far as I can figure out). So, by hardcoding the input
        # to '000013', we will get series 000013 and build a nifti named
        # '000013_000013.nii.gz' saved in pyneal/pyneal_scanner/data. Delete this file
        # at end of test
        seriesNum = '000013'
        getSeries.input = lambda x: seriesNum
        getSeries.getSeries_Siemens(scannerDirs)

        # return the module input to the normal __builtin__ input function
        getSeries.input = input

        # ensure output file created, then delete
        outputFile = join(paths['pynealScannerDir'], 'data',
                          '{}_{}.nii.gz'.format(seriesNum, seriesNum))
        assert os.path.exists(outputFile)
        os.remove(outputFile)

        # remove local paths from the config file
        helper_tools.cleanConfigFile(configFile)