#NEWLINE# def resampleNUCtoLSQ6Space( self ) : #NEWLINE# #INDENT# '\n            This function is called when useOriginalInput is True.  That means that the \n            non uniformity correction was applied to the native files.  In order to get\n            to the native space, we used the "lsq6" group.  We will use that group again \n            now to resample the NUC file back to lsq6 space.\n            \n            Can only be called on file handlers \n        ' #NEWLINE# if ( not rf . isFileHandler ( self . inputs [ 0 ] ) ) : #NEWLINE# #INDENT# print ( 'Error: resampleNUCtoLSQ6Space can only be called on file handlers. Goodbye.\n' ) #NEWLINE# sys . exit ( ) #NEWLINE# #UNINDENT# if ( ( self . initial_model == None ) and ( self . targetForLSQ6 == None ) ) : #NEWLINE# #INDENT# print ( 'Error: resampleNUCtoLSQ6Space does not know what to do without an initial model and without a target file for the LSQ6 stage. Sorry. Goodbye.\n' ) #NEWLINE# sys . exit ( ) #NEWLINE# #UNINDENT# self . addLSQ6NUCGroupToInputs ( ) #NEWLINE# nuCorrectedLSQ6 = [ ] #NEWLINE# nuCorrectedLSQ6Masks = [ ] #NEWLINE# lsq6SpaceTarget = None #NEWLINE# if self . initial_model : #NEWLINE# #INDENT# lsq6SpaceTarget = self . initial_model [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# lsq6SpaceTarget = self . targetForLSQ6 #NEWLINE# #UNINDENT# for inputFH in self . inputs : #NEWLINE# #INDENT# indexLsq6 = None #NEWLINE# for ( index , value ) in inputFH . groupNames . iteritems ( ) : #NEWLINE# #INDENT# if ( value == 'lsq6' ) : #NEWLINE# #INDENT# indexLsq6 = index #NEWLINE# #UNINDENT# #UNINDENT# if ( indexLsq6 != None ) : #NEWLINE# #INDENT# if inputFH . groupedFiles [ indexLsq6 ] . transforms . has_key ( lsq6SpaceTarget ) : #NEWLINE# #INDENT# transformToLSQ6 = inputFH . getLastXfm ( lsq6SpaceTarget , groupIndex = indexLsq6 ) #NEWLINE# outFileBase = ( fh . removeBaseAndExtension ( inputFH . getLastBasevol ( ) ) + '_lsq6.mnc' ) #NEWLINE# outFileDir = inputFH . resampledDir #NEWLINE# outFile = fh . createBaseName ( outFileDir , outFileBase ) #NEWLINE# nuCorrectedLSQ6 . append ( transformToLSQ6 ) #NEWLINE# resamplings = ma . mincresampleFileAndMask ( inputFH , lsq6SpaceTarget , nameForStage = 'mincresample NUC to LSQ6' , likeFile = lsq6SpaceTarget , transform = transformToLSQ6 , output = outFile , argArray = [ '-sinc' ] ) #NEWLINE# nuCorrectedLSQ6Masks . append ( resamplings . outputFilesMask [ 0 ] ) #NEWLINE# self . p . addPipeline ( resamplings . p ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# print ( ( '\nError: can not find the 6 parameter transformation between: %s and %s (in the function: resampleNUCtoLSQ6Space). Exiting now...\n' % ( inputFH . inputFileName , lsq6SpaceTarget . inputFileName ) ) ) #NEWLINE# sys . exit ( ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# print ( '\nError: we were not able to find the "lsq6" class of files during the non uniformity correction stage. Were trying to determine the transformation that resamples the non uniformity corrected file in native space to LSQ6 space. Exiting now...\n\n' ) #NEWLINE# sys . exit ( ) #NEWLINE# #UNINDENT# #UNINDENT# self . NUCorrectedLSQ6 = nuCorrectedLSQ6 #NEWLINE# self . NUCorrectedLSQ6Masks = nuCorrectedLSQ6Masks