class BRAINSClassPlugsInputSpec(CommandLineInputSpec): t1Volume = File(exists="True", argstr="--t1Volume %s") t2Volume = File(exists="True", argstr="--t2Volume %s") pdVolume = File(exists="True", argstr="--pdVolume %s") searchVolume = File(exists="True", argstr="--searchVolume %s") gmPlugs = traits.Either(traits.Bool, File, argstr="--gmPlugs %s") wmPlugs = traits.Either(traits.Bool, File, argstr="--wmPlugs %s") csfPlugs = traits.Either(traits.Bool, File, argstr="--csfPlugs %s") plugClassNames = traits.List("traits.Str", sep=",", argstr="--plugClassNames %s") t1ClassMeans = traits.List("traits.Float", sep=",", argstr="--t1ClassMeans %f") t2ClassMeans = traits.List("traits.Float", sep=",", argstr="--t2ClassMeans %f") pdClassMeans = traits.List("traits.Float", sep=",", argstr="--pdClassMeans %f") randomSeed = traits.Int(argstr="--randomSeed %d") numberOfPlugs = traits.Int(argstr="--numberOfPlugs %d") coverage = traits.Float(argstr="--coverage %f") permissiveness = traits.Float(argstr="--permissiveness %f") meanOutlier = traits.Float(argstr="--meanOutlier %f") varOutlier = traits.Float(argstr="--varOutlier %f") plugSize = traits.Float(argstr="--plugSize %f") partitions = traits.List("traits.Int", sep=",", argstr="--partitions %d") numberOfClassPlugs = traits.List("traits.Int", sep=",", argstr="--numberOfClassPlugs %d") bloodMode = traits.Enum("Manual", "Top", "Bottom", argstr="--bloodMode %s") bloodImage = traits.Enum("T1", "T2", "PD", argstr="--bloodImage %s") vbPlugs = File(exists="True", argstr="--vbPlugs %s")
class N4ITKInputSpec(CommandLineInputSpec): inputImageName = File(exists="True", argstr="--inputimage %s") maskImageName = File(exists="True", argstr="--maskimage %s") outputImageName = traits.Either(traits.Bool, File, argstr="--outputimage %s") outputBiasFieldName = traits.Either(traits.Bool, File, argstr="--outputbiasfield %s") Force2D = traits.Bool(argstr="--force2D ") numberOfIterations = traits.List("traits.Int", sep=",", argstr="--iterations %d") convergenceThreshold = traits.Float(argstr="--convergencethreshold %f") initialMeshResolution = traits.List("traits.Float", sep=",", argstr="--meshresolution %f") splineDistance = traits.Float(argstr="--splinedistance %f") shrinkFactor = traits.Int(argstr="--shrinkfactor %d") bsplineOrder = traits.Int(argstr="--bsplineorder %d") weightImageName = File(exists="True", argstr="--weightimage %s") alpha = traits.Float(argstr="--bsplinealpha %f") beta = traits.Float(argstr="--bsplinebeta %f") histogramSharpening = traits.List("traits.Float", sep=",", argstr="--histogramsharpening %f") biasFieldFullWidthAtHalfMaximum = traits.Float( argstr="--biasFieldFullWidthAtHalfMaximum %f") weinerFilterNoise = traits.Float(argstr="--weinerFilterNoise %f") numberOfHistogramBins = traits.Int(argstr="--numberOfHistogramBins %d")
class BRAINSTalairachInputSpec(CommandLineInputSpec): AC = traits.List("traits.Float", sep=",", argstr="--AC %f") ACisIndex = traits.Bool(argstr="--ACisIndex ") PC = traits.List("traits.Float", sep=",", argstr="--PC %f") PCisIndex = traits.Bool(argstr="--PCisIndex ") SLA = traits.List("traits.Float", sep=",", argstr="--SLA %f") SLAisIndex = traits.Bool(argstr="--SLAisIndex ") IRP = traits.List("traits.Float", sep=",", argstr="--IRP %f") IRPisIndex = traits.Bool(argstr="--IRPisIndex ") inputVolume = File(exists="True", argstr="--inputVolume %s") outputBox = traits.Either(traits.Bool, File, argstr="--outputBox %s") outputGrid = traits.Either(traits.Bool, File, argstr="--outputGrid %s")
class BRAINSDiscreteClassInputSpec(CommandLineInputSpec): inputVolume = File(exists="True", argstr="--inputVolume %s") subcorticalMask = File(exists="True", argstr="--subcorticalMask %s") outputVolume = traits.Either(traits.Bool, File, argstr="--outputVolume %s") subcorticalThreshold = traits.Float(argstr="--subcorticalThreshold %f") corticalThreshold = traits.Float(argstr="--corticalThreshold %f") csfThreshold = traits.Float(argstr="--csfThreshold %f")
class BRAINSApplySurfaceLabelsInputSpec(CommandLineInputSpec): inputLabelMap = File(exists="True", argstr="--inputLabelMap %s") inputSurface = File(exists="True", argstr="--inputSurface %s") cellDataName = traits.Str(exists="True", argstr="--cellDataName %s") outputSurface = traits.Either(traits.Bool, File, argstr="--outputSurface %s")
class DicomToNrrdConverterInputSpec(CommandLineInputSpec): inputDicomDirectory = Directory( exists = "True",argstr = "--inputDicomDirectory %s") outputDirectory = traits.Either(traits.Bool, Directory, argstr = "--outputDirectory %s") outputVolume = traits.Str( argstr = "--outputVolume %s") smallGradientThreshold = traits.Float( argstr = "--smallGradientThreshold %f") writeProtocolGradientsFile = traits.Bool( argstr = "--writeProtocolGradientsFile ") useIdentityMeaseurementFrame = traits.Bool( argstr = "--useIdentityMeaseurementFrame ") useBMatrixGradientDirections = traits.Bool( argstr = "--useBMatrixGradientDirections ")
class BRAINSTalairachMaskInputSpec(CommandLineInputSpec): inputVolume = File(exists="True", argstr="--inputVolume %s") talairachParameters = File(exists="True", argstr="--talairachParameters %s") talairachBox = File(exists="True", argstr="--talairachBox %s") hemisphereMode = traits.Enum("left", "right", "both", argstr="--hemisphereMode %s") expand = traits.Bool(argstr="--expand ") outputVolume = traits.Either(traits.Bool, File, argstr="--outputVolume %s")
class BRAINSMeasureSurfaceInputSpec(CommandLineInputSpec): inputSurface = File( exists = "True",argstr = "--inputSurface %s") arrayName = traits.Str( argstr = "--arrayName %s") labels = traits.List("traits.Str", sep = ",",argstr = "--labelNames %s") subjectId = traits.Str( argstr = "--subjectId %s") scanId = traits.Str( argstr = "--scanId %s") writeCsvFile = traits.Bool( argstr = "--writeCsvFile ") writeXmlFile = traits.Bool( argstr = "--writeXmlFile ") csvFile = traits.Either(traits.Bool, File, argstr = "--csvFile %s") xmlFile = traits.Either(traits.Bool, File, argstr = "--xmlFile %s") testDepth = traits.Bool( argstr = "--testDepth ") totalDepthResults = traits.List("traits.Float", sep = ",",argstr = "--totalDepthResults %f") gyralDepthResults = traits.List("traits.Float", sep = ",",argstr = "--gyralDepthResults %f") sulcalDepthResults = traits.List("traits.Float", sep = ",",argstr = "--sulcalDepthResults %f") testArea = traits.Bool( argstr = "--testArea ") totalAreaResults = traits.List("traits.Float", sep = ",",argstr = "--totalAreaResults %f") gyralAreaResults = traits.List("traits.Float", sep = ",",argstr = "--gyralAreaResults %f") sulcalAreaResults = traits.List("traits.Float", sep = ",",argstr = "--sulcalAreaResults %f") testCurvature = traits.Bool( argstr = "--testCurvature ") totalCurvatureResults = traits.List("traits.Float", sep = ",",argstr = "--totalCurvatureResults %f") gyralCurvatureResults = traits.List("traits.Float", sep = ",",argstr = "--gyralCurvatureResults %f") sulcalCurvatureResults = traits.List("traits.Float", sep = ",",argstr = "--sulcalCurvatureResults %f")
class BRAINSClassifyInputSpec(CommandLineInputSpec): t1Volume = File(exists="True", argstr="--t1Volume %s") t2Volume = File(exists="True", argstr="--t2Volume %s") pdVolume = File(exists="True", argstr="--pdVolume %s") gmPlugs = File(exists="True", argstr="--gmPlugs %s") wmPlugs = traits.Either(traits.Bool, File, argstr="--wmPlugs %s") csfPlugs = File(exists="True", argstr="--csfPlugs %s") bloodPlugs = File(exists="True", argstr="--bloodPlugs %s") BrainVolume = File(exists="True", argstr="--BrainVolume %s") classVolume = traits.Either(traits.Bool, File, argstr="--classVolume %s") grossTrim = traits.Float(argstr="--grossTrim %f") spatialTrim = traits.Float(argstr="--spatialTrim %f") x = traits.Bool(argstr="--x ") y = traits.Bool(argstr="--y ") z = traits.Bool(argstr="--z ") xx = traits.Bool(argstr="--xx ") yy = traits.Bool(argstr="--yy ") zz = traits.Bool(argstr="--zz ") xy = traits.Bool(argstr="--xy ") xz = traits.Bool(argstr="--xz ") yz = traits.Bool(argstr="--yz ") histogramEqualize = traits.Bool(argstr="--histogramEqualize ") generateSeperateImages = traits.Bool(argstr="--generateSeperateImages ") excludeVolume = File(exists="True", argstr="--excludeVolume %s")
from nipype.interfaces.base import CommandLine, CommandLineInputSpec, TraitedSpec import enthought.traits.api as traits import os from nipype.interfaces.traits import File from nipype.interfaces.traits import Directory from nipype.utils.misc import isdefined class test.xmlInputSpec(CommandLineInputSpec): houghEyeDetectorMode = traits.Int( argstr = "--houghEyeDetectorMode %d") inputTemplateModel = File( exists = "True",argstr = "--inputTemplateModel %s") inputLLSModel = File( exists = "True",argstr = "--inputLLSModel %s") inputEPCAModelMat = File( exists = "True",argstr = "--inputEPCAModelMat %s") inputEPCAModelTxt = File( exists = "True",argstr = "--inputEPCAModelTxt %s") inputVolume = File( exists = "True",argstr = "--inputVolume %s") outputVolume = traits.Either(traits.Bool, File, argstr = "--outputVolume %s") outputResampledVolume = traits.Either(traits.Bool, File, argstr = "--outputResampledVolume %s") outputTransform = traits.Either(traits.Bool, File, argstr = "--outputTransform %s") outputLandmarksInInputSpace = traits.Either(traits.Bool, File, argstr = "--outputLandmarksInInputSpace %s") outputLandmarksInACPCAlignedSpace = traits.Either(traits.Bool, File, argstr = "--outputLandmarksInACPCAlignedSpace %s") inputLandmarksPaired = File( exists = "True",argstr = "--inputLandmarksPaired %s") outputLandmarksPaired = traits.Either(traits.Bool, File, argstr = "--outputLandmarksPaired %s") outputMRML = traits.Either(traits.Bool, File, argstr = "--outputMRML %s") outputVerificationScript = traits.Either(traits.Bool, File, argstr = "--outputVerificationScript %s") mspQualityLevel = traits.Int( argstr = "--mspQualityLevel %d") otsuPercentileThreshold = traits.Float( argstr = "--otsuPercentileThreshold %f") acLowerBound = traits.Float( argstr = "--acLowerBound %f") cutOutHeadInOutputVolume = traits.Bool( argstr = "--cutOutHeadInOutputVolume ") outputUntransformedClippedVolume = traits.Either(traits.Bool, File, argstr = "--outputUntransformedClippedVolume %s") rescaleIntensities = traits.Bool( argstr = "--rescaleIntensities ") trimRescaledIntensities = traits.Float( argstr = "--trimRescaledIntensities %f") rescaleIntensitiesOutputRange = traits.List("traits.Int", sep = ",",argstr = "--rescaleIntensitiesOutputRange %d")
class Passenger(PrtEvent): """A passenger.""" mass = traits.Int() _loc = traits.Either(traits.Instance('pyprt.sim.station.Station'), traits.Instance('pyprt.sim.vehicle.BaseVehicle'), None) traits_view = ui.View( ui.Item(name='label'), ui.Item(name='ID'), ui.Item(name='loc'), ui.Item(name='mass'), # in kg ui.Item(name='trip_success'), ui.Item(name='wait_time', format_func=sec_to_hms), ui.Item(name='walk_time', format_func=sec_to_hms), ui.Item(name='ride_time', format_func=sec_to_hms), ui.Item(name='will_share'), ui.Item(name='src_station'), ui.Item(name='dest_station'), ui.Item(name='load_delay', format_func=sec_to_hms), ui.Item(name='unload_delay', format_func=sec_to_hms), style='readonly', handler=NoWritebackOnCloseHandler()) ## # Subset of passenger data in table format. ## table_editor = ui.TableEditor( ## columns = [ui_tc.ObjectColumn(name='ID', label='ID'), ## ui_tc.ObjectColumn(name='src_station', label='Origin'), ## ui_tc.ObjectColumn(name='dest_station', label='Destination'), ## ui_tc.ExpressionColumn(label='Waiting', ## expression='sec_to_hms(object.wait_time)', ## globals={'sec_to_hms':sec_to_hms}, ## tooltip='Time spent waiting'), ## ui_tc.ExpressionColumn(label='Riding', ## expression='sec_to_hms(object.ride_time)', ## globals={'sec_to_hms':sec_to_hms}, ## tooltip='Time spent riding'), ## ui_tc.ExpressionColumn(label='Walking', ## expression='sec_to_hms(object.walk_time)', ## globals={'sec_to_hms':sec_to_hms}, ## tooltip='Time spent walking'), ## ui_tc.ExpressionColumn(label='Total', ## expression='sec_to_hms(object.total_time)', ## globals={'sec_to_hms':sec_to_hms}, ## tooltip='Total time spent on trip'), ## ui_tc.ObjectColumn(name='trip_success', label='Success', ## tooltip='Sucessfully reached destination'), ## ui_tc.ObjectColumn(name='loc', label='Current Location') ## ], ## other_columns = [ui_tc.ObjectColumn(name='label', label='Label'), ## ui_tc.ObjectColumn(name='will_share', label='Will Share', ## tooltip='Willing to share vehicle when destinations match'), ## ui_tc.ObjectColumn(name='load_delay', label='Load Delay', ## tooltip='Time that passenger takes to embark'), ## ui_tc.ObjectColumn(name='unload_delay', label='Unload Delay', ## tooltip='Time that passenger takes to disembark'), ## ui_tc.ObjectColumn(name='mass', label='Mass', ## tooltip='Includes luggage (kg)') ## ], ## # more... ## deletable = False, ## editable=False, ## sortable = True, ## sort_model = False, ## auto_size = True, ## orientation = 'vertical', ## show_toolbar = True, ## reorderable = False, ## rows = 15, ## row_factory = traits.This) def __init__(self, time, ID, src_station, dest_station, load_delay, unload_delay, will_share, mass): super(Passenger, self).__init__(time, ID) self.src_station = src_station self.dest_station = dest_station self.load_delay = load_delay self.unload_delay = unload_delay self.will_share = will_share # Willing to share pod (if same dest) self.mass = mass self.trip_success = False self._loc = src_station # For the following, where start and end are times in seconds, with 0 being the start of the sim. self._wait_times = [[time, None, self._loc] ] # contains triples: [[start, end, loc], ...] self._walk_times = [ ] # containing pairs: [[start, end], [start, end], ...] self._ride_times = [ ] # contains triples: [[start, end, vehicle], [start, end, vehicle], ...] self._start_time = time self._end_time = None @property def wait_time(self): # in seconds total = 0 for start, end, loc in self._wait_times: if end is None: total += Sim.now() - start else: total += end - start return total @property def ride_time(self): # in seconds total = 0 for start, end, vehicle in self._ride_times: if end is None: total += Sim.now() - start else: total += end - start return total @property def walk_time(self): # in seconds total = 0 for start, end in self._walk_times: if end is None: total += Sim.now() - start else: total += end - start return total @property def total_time(self): if self._end_time is None: return Sim.now() - self._start_time else: return self._end_time - self._start_time def get_loc(self): return self._loc def set_loc(self, loc): """Changes the loc, and keeps track of how much time is spent in each mode of transit: waiting, riding, or walking.""" ### Track time spent in each mode of transit ### if self._loc is None: # Was walking self._walk_times[-1][1] = Sim.now() elif hasattr(self._loc, 'vehicle_mass'): # was in vehicle self._ride_times[-1][1] = Sim.now() elif hasattr(self._loc, 'platforms'): # was at station self._wait_times[-1][1] = Sim.now() else: raise Exception("Unknown loc type") ### Note if trip is completed. ### if loc is self.dest_station: self._end_time = Sim.now() self.trip_success = True ### More time tracking ### if not self.trip_success: if loc is None: self._walk_times.append([Sim.now(), None]) elif hasattr(loc, 'vehicle_mass'): self._ride_times.append([Sim.now(), None, loc]) # isinstance(loc, BaseVehicle) elif hasattr(loc, 'platforms'): self._wait_times.append([Sim.now(), None, loc]) # isinstance(loc, TrackSegment) else: raise Exception("Unknown loc type") self._loc = loc loc = property( get_loc, set_loc, doc="loc is expected to be a Station, a " "Vehicle, or None (which indicates walking from one station " "to another). Setting the loc has side-effects, see set_loc.") def walk(self, origin_station, dest_station, travel_time, cmd_msg, cmd_id): assert self._loc is origin_station assert travel_time >= 0 assert isinstance(cmd_msg, api.CtrlCmdPassengerWalk) assert isinstance(cmd_id, int) self.loc = None common.AlarmClock(Sim.now() + travel_time, self._post_walk, dest_station, cmd_msg, cmd_id) def _post_walk(self, dest_station, cmd_msg, cmd_id): """Updates stats, changes location, and sends a SimCompletePassengerWalk message. To be called once the walk is complete.""" assert self._loc is None self.loc = dest_station msg = api.SimCompletePassengerWalk() msg.msgID = cmd_id msg.cmd.CopyFrom(cmd_msg) msg.time = Sim.now() common.interface.send(api.SIM_COMPLETE_PASSENGER_WALK, msg) def fill_PassengerStatus(self, ps): ps.pID = self.ID # I'd much rather use isinstance checks, but circular imports are killing me if self._loc is None: ps.loc_type = api.WALKING ps.locID = api.NONE_ID elif hasattr(self._loc, 'vehicle_mass'): # a vehicle ps.loc_type = api.VEHICLE ps.locID = self._loc.ID elif hasattr(self._loc, 'platforms'): # a station ps.loc_type = api.STATION ps.locID = self._loc.ID else: raise Exception, "Unknown passenger location type: %s" % self._loc ps.src_stationID = self.src_station.ID ps.dest_stationID = self.dest_station.ID ps.creation_time = self._start_time ps.mass = self.mass ps.trip_success = self.trip_success