rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
'I:D:vh', | 'R:I:D:vh', | def Usage(): print __doc__ % __VERSION__ sys.exit(1) |
if not self.info.exclude: indent = self.INDENT in_indent = self.INDENT*2 rename = self.info.rename or self.enum.name full_name = self.enum.FullName() unnamed_enum = False if rename.startswith('$_') or rename.startswith('._'): unique_number = hash(self.info.include) unnamed_enum = True self.ExportUniqueInt(codeunit) ful... | if self.info.exclude: return indent = self.INDENT in_indent = self.INDENT*2 rename = self.info.rename or self.enum.name full_name = self.enum.FullName() unnamed_enum = False if rename.startswith('$_') or rename.startswith('._'): unnamed_enum = True code = '' if not unnamed_enum: code += indent + namespaces.python | def Export(self, codeunit, exported_names): if not self.info.exclude: indent = self.INDENT in_indent = self.INDENT*2 rename = self.info.rename or self.enum.name full_name = self.enum.FullName() unnamed_enum = False if rename.startswith('$_') or rename.startswith('._'): unique_number = hash(self.info.include) unnamed_en... |
for name in self.enum.values: rename = self.info[name].rename or name value_fullname = self.enum.ValueFullName(name) | for name in self.enum.values: rename = self.info[name].rename or name value_fullname = self.enum.ValueFullName(name) if not unnamed_enum: | def Export(self, codeunit, exported_names): if not self.info.exclude: indent = self.INDENT in_indent = self.INDENT*2 rename = self.info.rename or self.enum.name full_name = self.enum.FullName() unnamed_enum = False if rename.startswith('$_') or rename.startswith('._'): unique_number = hash(self.info.include) unnamed_en... |
if self.info.export_values or unnamed_enum: code += in_indent + '.export_values()\n' code += indent + ';\n\n' codeunit.Write('module', code) exported_names[self.enum.FullName()] = 1 def ExportUniqueInt(self, codeunit): write = lambda s: codeunit.Write('declaration', s) write('// Unique type for unnamed enums\n') writ... | else: code += indent + namespaces.python code += 'scope().attr("%s") = (int)%s;\n' % (rename, value_fullname ) if self.info.export_values and not unnamed_enum: code += in_indent + '.export_values()\n' if not unnamed_enum: code += indent + ';\n' code += '\n' codeunit.Write('module', code) exported_names[self.enum.FullNa... | def Export(self, codeunit, exported_names): if not self.info.exclude: indent = self.INDENT in_indent = self.INDENT*2 rename = self.info.rename or self.enum.name full_name = self.enum.FullName() unnamed_enum = False if rename.startswith('$_') or rename.startswith('._'): unique_number = hash(self.info.include) unnamed_en... |
if self.cache_dir is None: return None | def GetCache(self, header, interface, tail): if self.cache_dir is None: return None key = (header, interface, tail) # try memory cache first if key in self.mem_cache: return self.mem_cache[key] # get the cache from the disk header = self.FindHeader(header) cache_file = self.CacheFileName(interface) if os.path.isfile(... | |
>>> check(y.array((1.2, 3.4))); >>> check(y.array((1.2, 3.4), "Double")); >>> check(y.array((1.2, 3.4), "Double", (1,2,1))); >>> check(y.array((1.2, 3.4), "Double", (2,1,1), false)); >>> check(y.array((1.2, 3.4), "Double", (2,), true, true)); | >>> check(y.factory((1.2, 3.4))); >>> check(y.factory((1.2, 3.4), "Double")); >>> check(y.factory((1.2, 3.4), "Double", (1,2,1))); >>> check(y.factory((1.2, 3.4), "Double", (2,1,1), false)); >>> check(y.factory((1.2, 3.4), "Double", (2,), true, true)); | def _numarray_tests(): ''' >>> from numpy_ext import * >>> x = new_array() >>> y = x.copy() >>> p = _printer() >>> check = p.check >>> exercise_numarray(x, p) >>> check(y.astype()); >>> check(y.argmax()); >>> check(y.argmax(0)); >>> check(y.argmin()); >>> check(y.argmin(0)); >>> check(y.argsort()); >>> check(y.args... |
self.__infos = otherInfo.__infos.copy() self.__attributes = otherInfo.__attributes.copy() | self.__infos = copy.deepcopy(otherInfo.__infos) self.__attributes = copy.deepcopy(otherInfo.__attributes) | def __init__(self, otherInfo=None): self.__infos = {} self.__attributes = {} if otherInfo is not None: self.__infos = otherInfo.__infos.copy() self.__attributes = otherInfo.__attributes.copy() |
def __init__(self, name, include, tail=None, otherOption=None): DeclarationInfo.__init__(self, otherOption) | def __init__(self, name, include, tail=None, otherInfo=None): DeclarationInfo.__init__(self, otherInfo) | def __init__(self, name, include, tail=None, otherOption=None): DeclarationInfo.__init__(self, otherOption) self._Attribute('name', name) self._Attribute('include', include) # create a ClassExporter exporter = ClassExporter(InfoWrapper(self), tail) exporters.exporters.append(exporter) |
def testReturnPy(self): | def test_return_py(self): | def testReturnPy(self): |
class D(A): | class X(A): | def testReturnPy(self): |
return 'D.f' | return 'X.f' | def f(self): return 'D.f' |
d = D() | x = X() | def f(self): return 'D.f' |
self.failUnlessEqual ('D.f', d.f()) self.failUnlessEqual ('D.f', call_f(d)) | self.failUnlessEqual ('X.f', x.f()) self.failUnlessEqual ('X.f', call_f(x)) | def f(self): return 'D.f' |
>>> class myrational(Rational): ... __dict_defines_state__ = 1 ... | ... def new_method(self): | |
>>> class myworld(world): ... def __init__(self): ... world.__init__(self, 'anywhere') ... self.x = 1 ... | >>> u=pickle.loads(s) | ... def new_method(self): |
>>> class myunsafeworld(myworld): ... __getstate_manages_dict__ = 1 ... | ... def __init__(self): | |
def setOuput(self): | def setOutput(self): | def setOuput(self): |
command = javax.swing.JTextField(5) temppanel2 = javax.swing.JPanel() temppanel2.add(javax.swing.JLabel("Command")) temppanel2.add(command) | def whenAddressChanged(event) : global addressChanged, commandChanged if (address.text != "") : # address only changed if a value was entered addressChanged = True if (commandChanged and addressChanged) : # if both have been changed enterButton.setEnabled(True) return | |
if str(config[c]).lower() in ("true", "t", "1"): | if str(config[c]).lower() in ("true", "t"): | def readLocalConfig(self): global config try: with open(CONFIG_FILE, 'r') as f: newConfig = json.load(f) self.cbLog("debug", "Read local config") config.update(newConfig) except Exception as ex: self.cbLog("warning", "Local config does not exist or file is corrupt. Exception: " + str(type(ex)) + str(ex.args)) for c in ... |
elif str(config[c]).lower() in ("false", "f", "0"): | elif str(config[c]).lower() in ("false", "f"): | def readLocalConfig(self): global config try: with open(CONFIG_FILE, 'r') as f: newConfig = json.load(f) self.cbLog("debug", "Read local config") config.update(newConfig) except Exception as ex: self.cbLog("warning", "Local config does not exist or file is corrupt. Exception: " + str(type(ex)) + str(ex.args)) for c in ... |
_defaults_for_fieldname = {'sizeof_hdr': HEADER_SIZE, 'scale_factor':1.} | _defaults_for_fieldname = { 'sizeof_hdr': HEADER_SIZE, 'extents': 16384, 'regular': 'r', 'hkey_un0': ' ', 'vox_units': 'mm', 'scale_factor':1.} | def load_image(self, filename): |
'xsize': image.xsize, 'xsize': image.xsize, 'xsize': image.xsize} | 'ysize': image.ysize, 'zsize': image.zsize, 'tsize': image.tsize, 'glmin': amin(data_magnitude.flat), 'glmax': amax(data_magnitude.flat), 'orient': '\0'} | def write_hdr(self, filename): "Write ANALYZE format header (.hdr) file." image = self.image imagevalues = { 'datatype': self.datatype, 'bitpix': datatype2bitpix[self.datatype], 'ndim': image.ndim, 'xdim': image.xdim, 'ydim': image.ydim, 'zdim': image.zdim, 'tdim': image.tdim, 'xsize': image.xsize, 'xsize': image.xsize... |
return imagevalues.get(fieldname) or\ self._default_field_value(fieldname, fieldformat) | if imagevalues.has_key(fieldname): return imagevalues[fieldname] if hasattr(image, fieldname): return getattr(image, fieldname) return self._default_field_value(fieldname, fieldformat) | def fieldvalue(fieldname, fieldformat): return imagevalues.get(fieldname) or\ self._default_field_value(fieldname, fieldformat) |
print "CASTING" | def write_img(self, filename): "Write ANALYZE format image (.img) file." imagedata = self.image.data | |
for sublist in listoflists: finallist += sublist | for sublist in listoflists: finallist.extend(sublist) | def _concatenate(listoflists): "Flatten a list of lists by one degree." finallist = [] for sublist in listoflists: finallist += sublist return finallist |
def writeImage(image, filestem, datatype=None, targetdim=3): | def writeImage(image, filestem, datatype=None, targetdim=None): | def writeImage(image, filestem, datatype=None, targetdim=3): """ Write the given image to the filesystem as one or more Analyze7.5 format hdr/img pairs. @param filestem: will be prepended to each hdr and img file. @param targetdim: indicates the dimensionality of data to be written into a single hdr/img pair. For ex... |
mask = checkerboard(*(data.shape[-2:])) | mask = checkerboard(*(image.data.shape[-2:])) | def run(self, image): |
modulename = "imaging.tools.%s"%toolname | modulename = "imaging.tools.%s"%classname | def getToolByName(toolname): if not tool_map.has_key(toolname): raise ValueError("No tool called '%s'."%toolname) classname = tool_map[toolname] modulename = "imaging.tools.%s"%toolname try: return import_from(modulename, toolname) except ImportError: raise RuntimeError("Tool class %s.%s not found."%(modulename.toolnam... |
return import_from(modulename, toolname) | return import_from(modulename, classname) | def getToolByName(toolname): if not tool_map.has_key(toolname): raise ValueError("No tool called '%s'."%toolname) classname = tool_map[toolname] modulename = "imaging.tools.%s"%toolname try: return import_from(modulename, toolname) except ImportError: raise RuntimeError("Tool class %s.%s not found."%(modulename.toolnam... |
raise RuntimeError("Tool class %s.%s not found."%(modulename.toolname)) | raise RuntimeError("Tool class %s.%s not found."%(modulename,classname)) | def getToolByName(toolname): if not tool_map.has_key(toolname): raise ValueError("No tool called '%s'."%toolname) classname = tool_map[toolname] modulename = "imaging.tools.%s"%toolname try: return import_from(modulename, toolname) except ImportError: raise RuntimeError("Tool class %s.%s not found."%(modulename.toolnam... |
print (phi,theta,psi) | def make_hdr(self): "Pack a NIFTI format header." # (un)rotation is handled like this: take the image as transformed with # 2 rotations, S, Rb (S is the xform from scanner space into the # data-ordering in the FID file, Rb is the xform applied by slicing # coronal-wise, sagital-wise, etc) # then I = Rb(psi)*Rb(theta)*R... | |
print Qscanner print Qobl print Qform | def make_hdr(self): "Pack a NIFTI format header." # (un)rotation is handled like this: take the image as transformed with # 2 rotations, S, Rb (S is the xform from scanner space into the # data-ordering in the FID file, Rb is the xform applied by slicing # coronal-wise, sagital-wise, etc) # then I = Rb(psi)*Rb(theta)*R... | |
B = empty((2,n_pe), Float) | B = empty((2,n_fe), Float) | def run(self, image): if not image.ref_data: self.log("No reference volume, quitting") return if len(image.ref_vols) > 1: self.log("Could be performing Balanced Phase Correction!") |
for slice in vol: slice[:] = apply_phase_correction(slice, Correction) | vol[:] = apply_phase_correction(vol, Correction) | def run(self, image): if not image.ref_data: self.log("No reference volume, quitting") return if len(image.ref_vols) > 1: self.log("Could be performing Balanced Phase Correction!") |
elif self._procpar.pslabel[0] == 'Vsparse': | elif self._procpar.pslabel[0] in ('epidw', 'Vsparse') and\ not self.spinecho: | def _get_nseg(self): # !!!!!! HEY BEN WHAT IS THE sparse SEQUENCE !!!! # Leon's "spare" sequence is really the EPI sequence with delay. if self.pulse_sequence in ('epi','tepi','sparse','spare'): return int(self.petable_name[-2]) elif self._procpar.pslabel[0] == 'Vsparse': return int(self.petable_name[-1]) elif self.pul... |
"Could not identify sequence: %s" % (pulse_sequence)) | "Could not identify sequence: %s" % (self.pulse_sequence)) | def _get_nseg(self): # !!!!!! HEY BEN WHAT IS THE sparse SEQUENCE !!!! # Leon's "spare" sequence is really the EPI sequence with delay. if self.pulse_sequence in ('epi','tepi','sparse','spare'): return int(self.petable_name[-2]) elif self._procpar.pslabel[0] == 'Vsparse': return int(self.petable_name[-1]) elif self.pul... |
cmap=self.cmap, norm=self.norm) | cmap=self.cmap, norm=self.norm, origin="lower") | def setData(self, data, norm=None): ax = self.getAxes() |
cmap=self.cmap, norm=norm)) | cmap=self.cmap, norm=norm, origin="lower")) | def setData(self, data, norm=None): ax = self.getAxes() |
asym_time = image._procpar.asym_time[1] | asym_times = image._procpar.asym_time | def run(self, image): |
phase_map = (phase_map/asym_time).astype(Float32) | for vol in range(image.tdim-1): asym_time = asym_times[vol] - asym_times[vol+1] phase_map[vol] = (phase_map[vol]/asym_time).astype(Float32) | def run(self, image): |
n_pe = CachedReadOnlyProperty(lambda self: self._procpar.nv[0], "") | isepi = CachedReadOnlyProperty( lambda self: self.pulse_sequence.find("epi") != -1, "") n_pe = CachedReadOnlyProperty(lambda self: self.isepi and \ self._procpar.nf[0] or \ self._procpar.nv[0], "") | def cached_getter(self): if not hasattr(self, "_propvals"): self._propvals = {} return self._propvals.setdefault(key, getter(self)) |
isepi = CachedReadOnlyProperty( lambda self: self.pulse_sequence.find("epi") != -1, "") | def cached_getter(self): if not hasattr(self, "_propvals"): self._propvals = {} return self._propvals.setdefault(key, getter(self)) | |
}[winName] | }.get(winName) | def getWindow(winName, xSize, ySize): """ generates a 2D window in following manner: outerproduct(window(ySize), window(xSize)) @param winName: name of the window; can be blackman, hamming, or hanning """ #actually gets a KeyError on a bad winName, should fix later window = { "blackman": blackman, "hamming": hamming, ... |
raise "unsupported window type: %s"%winName | raise ValueError("unsupported window type: %s"%winName) | def getWindow(winName, xSize, ySize): """ generates a 2D window in following manner: outerproduct(window(ySize), window(xSize)) @param winName: name of the window; can be blackman, hamming, or hanning """ #actually gets a KeyError on a bad winName, should fix later window = { "blackman": blackman, "hamming": hamming, ... |
if class_list.count(read_op) > 1: n = 1 while opseq[n:] != []: n += class_list[n:].index(read_op) opseq.__delitem__(n) class_list.__delitem__(n) | op_count = class_list.count(read_op) n = 1 while op_count > 1: n += class_list[n:].index(read_op) opseq.__delitem__(n) class_list.__delitem__(n) op_count -= 1 | def confirmOps(self, opseq): """This routine currently looks at the file i/o ops to make sure they are in a sane order. This routine might be expanded to double-check other sequence requirements """ # make sure ReadImage is first op and only happens once, # if not change things around class_list = [opclass for (opclass... |
print "warning! Operation sequence doesn't end with "\ | print "WARNING! Operation sequence doesn't end with "\ | def confirmOps(self, opseq): """This routine currently looks at the file i/o ops to make sure they are in a sane order. This routine might be expanded to double-check other sequence requirements """ # make sure ReadImage is first op and only happens once, # if not change things around class_list = [opclass for (opclass... |
if not (self.running('ReadImage') and self.running('WriteImage')): | if not (self._running('ReadImage', options.operations) and \ self._running('WriteImage', options.operations)): | def getOptions(self): """ Bundle command-line arguments and options into a single options object, including a resolved list of callable data operations. Uses OptionParser to fill in the options list from command line input; appends volume range specifications, and input/output directories as options; asks for an index... |
return fromstring(data, Complex32) | return fromstring( fromstring(data,numtype).astype(Float32).tostring(), Complex32) | def complex_fromstring(data, numtype): if sys.byteorder == "little": return fromstring( fromstring(data, numtype).byteswapped().astype(Float32).tostring(), Complex32) else: return fromstring(data, Complex32) |
self.masked_avg(take(phs_vol[z], pos_order[:n_pe/4-1])) | self.masked_avg(take(phs_vol[z], pos_order[1:n_pe/4])) | def run(self, image): # basic tasks here: # 1: data preparation # 2: phase unwrapping # 3: find mean phase lines (2 means or 4, depending on sequence) # 4: solve for linear coefficients # 5: create correction matrix from coefs # 6: apply correction to all image volumes # # *all linearly-sampled data can be treated in a... |
print sres | def run(self, image): # basic tasks here: # 1: data preparation # 2: phase unwrapping # 3: find mean phase lines (2 means or 4, depending on sequence) # 4: solve for linear coefficients # 5: create correction matrix from coefs # 6: apply correction to all image volumes # # *all linearly-sampled data can be treated in a... | |
print selected | def run(self, image): # basic tasks here: # 1: data preparation # 2: phase unwrapping # 3: find mean phase lines (2 means or 4, depending on sequence) # 4: solve for linear coefficients # 5: create correction matrix from coefs # 6: apply correction to all image volumes # # *all linearly-sampled data can be treated in a... | |
self.coefs = tuple(matrixmultiply(diag([1,1,1,1,1,1]),asarray(v))) | self.coefs = v | def run(self, image): # basic tasks here: # 1: data preparation # 2: phase unwrapping # 3: find mean phase lines (2 means or 4, depending on sequence) # 4: solve for linear coefficients # 5: create correction matrix from coefs # 6: apply correction to all image volumes # # *all linearly-sampled data can be treated in a... |
if self.pulse_sequence == "gems" and self.n_transients==1: volume[slice,pe] = (trace - bias).astype(Complex32) else: volume[slice,pe] = trace | if self.pulse_sequence == "gems" and self.n_transients>1: volume[slice,pe] = trace else: volume[slice,pe] = (trace - bias).astype(Complex32) | def _read_asems_ncsnn_volume(self, fidfile, vol): """ Reads one volume from an asems_ncsnn FID file. @return: block of data with shape (nslice*n_pe, n_fe_true) """ volume = empty((self.nslice, self.n_pe, self.n_fe_true), Complex32) for pe in range(self.n_pe): block = fidfile.getBlock(pe*self.nvol + vol) bias = complex(... |
return (ndim,)+(1,)*(4-ndim)+shape def subimage(image, data): return BaseImage(data, image.xsize, image.ysize, image.zsize, image.tsize, image.x0, image.y0, image.z0) | return (ndim,) + (0,)*(4-ndim) + shape | def get_dims(data): """ Extract ndim, tdim, zdim, ydim, and xdim from data shape. @return: (ndim, tdim, zdim, ydim, xdim) """ shape = data.shape ndim = len(shape) if ndim < 2 or ndim > 4: raise ValueError("data shape %s must be 2, 3, or 4 dimensional"%shape) return (ndim,)+(1,)*(4-ndim)+shape |
def subImage(self, subnum): return subimage(self, self.data[subnum]) | def subImage(self, subnum): return BaseImage(self.data[subnum], self.xsize, self.ysize, self.zsize, self.tsize, self.x0, self.y0, self.z0) | def subImage(self, subnum): return subimage(self, self.data[subnum]) |
for subdata in self.data: yield subimage(self, subdata) | for subnum in xrange(len(self.data)): yield self.subImage(subnum) | def subImages(self): for subdata in self.data: yield subimage(self, subdata) |
readers = {} writers = {} | _readers = { "analyze": ("imaging.analyze","readImage"), "fid": ("imaging.varian.FidImage","FidImage"), "fdf": ("imaging.varian.FDFImage","FDFImage")} _writers = { "analyze": ("imaging.analyze","writeImage")} def _import((modulename, objectname)): module = __import__(modulename, globals(), locals(), (objectname,)) r... | def subImages(self): for subdata in self.data: yield subimage(self, subdata) |
def run(self, params, image): pass | def log(self, message): print "[%s]: %s"%(self.__class__.__name__, message) def run(self, image): pass class RunLogger (object): """ """ _magic_string = " def __init__(self, ostream=sys.stdout): self.ostream = ostream print >> self.ostream, self._magic_string def _format_doc(self, doc): for line in (doc or "... | def run(self, params, image): pass |
system. (Preferrably, an attribute of the EpiRecon tool class, once that class is implemented.) | system. | def run(self, params, image): pass |
print "analyzing slice %d"%(z) | def run(self, image): if not image.ref_data: self.log("No reference volume, quitting") return if len(image.ref_vols) > 1: self.log("Could be performing Balanced Phase Correction!") | |
"tuple":tuple} | "tuple":tuple_valuator} | def bool_valuator(val): if type(val)==BooleanType: return val lowerstr = val.lower() if lowerstr == "true": return True elif lowerstr == "false": return False else: raise ValueError( "Invalid boolean specifier '%s'. Must be either 'true' or 'false'."%\ lowerstr) |
return valspec is not None and self.valuator(valspec) or valspec | if valspec is None: return valspec else: return self.valuator(valspec) | def valuate(self, valspec): """ Evaluates valspec (a string) to the appropriate value according to the type of self. """ # don't valuate None, especially not as a string return valspec is not None and self.valuator(valspec) or valspec |
paramval = getattr(operation, parameter.name) | paramval = str(getattr(operation, parameter.name)) if paramval.find("%")>0: paramval = paramval.split("%")[0]+"%%"+paramval.split("%")[1] | def logop(self, operation): """ Writes name and parameters of operations, in the same format as the config file. The intention is to record the provenance of analyses and facilitate reproduction of results. """ self._format_doc(operation.__class__.__doc__) print >> self.ostream, "#[%s]"%operation.__class__.__name__ fo... |
print len(field_formats),len(values) | def load_header(self, filename): "Load Analyze7.5 header from the given filename" | |
map(self.__setattr__, zip(field_formats, values)) | map(self.__setattr__, struct_fields.keys(), values) | def load_header(self, filename): "Load Analyze7.5 header from the given filename" |
numtype = datatype2typecode[(self.datatype,self.bitpix)] new_numtype = self.datatype==COMPLEX and Complex32 or Float32 datasize = xdim*ydim*zdim*tdim*bytepix image = fromstring(file(filename).read(datasize),numtype)\ .astype(new_numtype) | numtype = datatype2typecode[self.datatype] | def load_image(self, filename): |
Write images in Analyze7.5 format. | Write a given image into a single Analyze7.5 format hdr/img pair. | def load_image(self, filename): |
self.write_header(headername) self.write_image(imagename) def write_header(self, filename): | self.write_hdr(headername) self.write_img(imagename) def write_hdr(self, filename): | def write(self, filestem): "Write ANALYZE format header, image file pair." headername, imagename = "%s.hdr"%filestem, "%s.img"%filestem self.write_header(headername) self.write_image(imagename) |
def write_image(self, filename): | def write_img(self, filename): | def write_image(self, filename): "Write ANALYZE format image (.img) file." imagedata = self.image.data |
if self.datatype != COMPLEX: imagedata = abs(imagedata) | print "CASTING" | def write_image(self, filename): "Write ANALYZE format image (.img) file." imagedata = self.image.data |
def writeImage(image, filename, datatype=None): writer = AnalyzeWriter(image, datatype=datatype) writer.write(filename) | def _concatenate(listoflists): "Flatten a list of lists by one degree." finallist = [] for sublist in listoflists: finallist += sublist return finallist | def writeImage(image, filename, datatype=None): writer = AnalyzeWriter(image, datatype=datatype) writer.write(filename) |
<menu action='Tools'> | <menu action='ToolsMenu'> <menu action='SizeMenu'> <menuitem action='1x'/> <menuitem action='2x'/> <menuitem action='4x'/> <menuitem action='6x'/> <menuitem action='8x'/> </menu> | def imag_xform(data): return data.imag |
table.attach(self.menubar, 0, 2, 0, 1) | table.attach(self.menubar, 0, 2, 0, 1, yoptions=0) | def __init__(self, data, dim_names=[], title="sliceview", cmap=p.cm.bone): self.data = p.asarray(data) |
table.attach(self.control_panel, 0, 1, 1, 2) | table.attach(self.control_panel, 0, 1, 1, 2, xoptions=0, yoptions=0) | def __init__(self, data, dim_names=[], title="sliceview", cmap=p.cm.bone): self.data = p.asarray(data) |
table.attach(self.rowplot, 1, 2, 1, 2) | table.attach(self.rowplot, 1, 2, 1, 2, xoptions=0, yoptions=0) | def __init__(self, data, dim_names=[], title="sliceview", cmap=p.cm.bone): self.data = p.asarray(data) |
table.attach(self.colplot, 0, 1, 2, 3) | table.attach(self.colplot, 0, 1, 2, 3, xoptions=0, yoptions=0) | def __init__(self, data, dim_names=[], title="sliceview", cmap=p.cm.bone): self.data = p.asarray(data) |
self.sliceplot.set_size_request(400, 400) | self.sliceplot.set_size_request(64*4+50, 64*4+50) | def __init__(self, data, dim_names=[], title="sliceview", cmap=p.cm.bone): self.data = p.asarray(data) |
table.attach(self.sliceplot, 1, 2, 2, 3) | scrollwin.add_with_viewport(self.sliceplot) table.attach(scrollwin, 1, 2, 2, 3) | def __init__(self, data, dim_names=[], title="sliceview", cmap=p.cm.bone): self.data = p.asarray(data) |
self.status.set_size_request(200,30) table.attach(self.status, 0, 2, 3, 4) | self.status.set_size_request(600,40) table.attach(self.status, 0, 2, 3, 4, xoptions=0, yoptions=0) | def __init__(self, data, dim_names=[], title="sliceview", cmap=p.cm.bone): self.data = p.asarray(data) |
self.set_default_size(600,450) | self.set_default_size(600,670) | def __init__(self, data, dim_names=[], title="sliceview", cmap=p.cm.bone): self.data = p.asarray(data) |
self.sliceplot.setData(self.getSlice(), norm=self.norm) | cset = self.sliceplot.setData(self.getSlice(), norm=self.norm) | def updateSlice(self): self.setNorm() self.sliceplot.setData(self.getSlice(), norm=self.norm) self.rowplot.setData(self.getRow()) self.colplot.setData(self.getCol()) self.status.cbar.setRange(self.sliceDataRange(), norm=self.norm) |
self.tools_menu = ContourToolWin(self.sliceplot.getAxes()) | self.contour_tools = ContourToolWin(self.sliceplot, self) | def launch_contour_tool(self, action): self.tools_menu = ContourToolWin(self.sliceplot.getAxes()) |
( "Tools", None, "_Tools" ), ( "ToolsMenu", None, "_Tools"), | ( "ToolsMenu", None, "_Tools" ), ( "SizeMenu", None, "_Image Size" ), | def _create_action_group(self): entries = ( ( "FileMenu", None, "_File" ), ( "Tools", None, "_Tools" ), ( "ToolsMenu", None, "_Tools"), ( "Save Image", gtk.STOCK_SAVE, "_Save Image", "<control>S", "Saves current slice as PNG", self.activate_action ), ( "Save Montage", gtk.STOCK_SAVE, "_Save Montage", "<control><shift>S... |
self.activate_action ) | self.launch_contour_tool ) ) size_toggles = ( ( "1x", None, "_1x", None, "", 1 ), ( "2x", None, "_2x", None, "", 2 ), ( "4x", None, "_4x", None, "", 4 ), ( "6x", None, "_6x", None, "", 6 ), ( "8x", None, "_8x", None, "", 8 ) | def _create_action_group(self): entries = ( ( "FileMenu", None, "_File" ), ( "Tools", None, "_Tools" ), ( "ToolsMenu", None, "_Tools"), ( "Save Image", gtk.STOCK_SAVE, "_Save Image", "<control>S", "Saves current slice as PNG", self.activate_action ), ( "Save Montage", gtk.STOCK_SAVE, "_Save Montage", "<control><shift>S... |
class ContourToolWin (gtk.Window): def __init__(self, obs_slice, parent): self.padre = parent self.sliceplot = obs_slice self.hbox = gtk.HBox(spacing=4) self.levSlider = gtk.VScale(gtk.Adjustment(7, 2, 20, 1, 1)) self.levSlider.set_digits(0) self.levSlider.set_value_pos(gtk.POS_TOP) self.levSlider.get_adjustment().con... | def _create_action_group(self): entries = ( ( "FileMenu", None, "_File" ), ( "Tools", None, "_Tools" ), ( "ToolsMenu", None, "_Tools"), ( "Save Image", gtk.STOCK_SAVE, "_Save Image", "<control>S", "Saves current slice as PNG", self.activate_action ), ( "Save Montage", gtk.STOCK_SAVE, "_Save Montage", "<control><shift>S... | |
class ContourToolWin (gtk.Window): def __init__(self): gtk.Window.__init_(self) self.set_title('Contour Plot Controls') self.set_default_size(200,100) table = gtk.Table(2,1, False) self.add(table) self.slider = gtk.VScale(gtk.Adjustment(10,2,20,1,1)) self.slider.set_digits(0) self.slider.set_value_pos(gtk.POS_TOP) | def spinnerHandler(self, adj): newval = int(adj.value) row_adj = self.row_spinner.get_adjustment() col_adj = self.col_spinner.get_adjustment() | |
fig = p.Figure(figsize=p.figaspect(data)) ax = fig.add_axes([0.05, 0.1, 0.85, 0.85]) | self.hasContours = False self.contourLevels = 7 fig = p.Figure(figsize=(28,28)) ax = fig.add_axes([.5*(1-4/8.)+.02, .5*(1-4/8.)+.02, 4/8., 4/8.]) | def __init__(self, data, x, y, cmap=p.cm.bone, norm=None): self.norm = None fig = p.Figure(figsize=p.figaspect(data)) ax = fig.add_axes([0.05, 0.1, 0.85, 0.85]) ax.yaxis.tick_right() ax.title.set_y(1.05) FigureCanvas.__init__(self, fig) self.cmap = cmap self.setData(data, norm=norm) self._init_crosshairs(x, y) |
return cset def killContour(self): ax = self.getAxes() ax.collections = [] self.hasContours = False self.draw() | def setData(self, data, norm=None): ax = self.getAxes() | |
fig.add_axes((0.05, 0.55, 0.9, 0.3)) | fig.add_axes((0.05, 0.4, 0.9, 0.3)) | def __init__(self, range, cmap=p.cm.bone, norm=None): fig = p.Figure(figsize = (5,0.5)) fig.add_axes((0.05, 0.55, 0.9, 0.3)) FigureCanvas.__init__(self, fig) self.figure.axes[0].yaxis.set_visible(False) self.cmap = cmap self.draw() self.setRange(range, norm=norm) |
pdb.run('sliceview(randn(6,6))') | pdb.run('sliceview(fmap.data)', globals=globals(), locals=locals()) | def push_items(self, pxbuf, avbuf): self.av_stat.push(self.av_context, avbuf) self.px_stat.push(self.px_context, pxbuf) |
outerproduct(arange(fMap.xdim), ones(fMap.xdim)) | outerproduct(arange(fMap.ydim), ones(fMap.ydim)) | def run(self, image): "Correct for Nyquist ghosting due to field inhomogeneity." |
shift_width = a.shape[0]/2 shift(tmp, 0, shift_width) | shift_width = a.shape[-1]/2 - 1 | def shifted_fft(a): tmp = a.copy() shift_width = a.shape[0]/2 shift(tmp, 0, shift_width) tmp = fft(tmp) shift(tmp, 0, shift_width) return tmp |
shift_width = a.shape[0]/2 | shift_width = a.shape[-1]/2 + 1 | def shifted_inverse_fft(a): tmp = a.copy() shift_width = a.shape[0]/2 shift(tmp, 0, shift_width) tmp = inverse_fft(tmp) shift(tmp, 0, shift_width) return tmp |
shift(tmp, 0, shift_width) | def shifted_inverse_fft(a): tmp = a.copy() shift_width = a.shape[0]/2 shift(tmp, 0, shift_width) tmp = inverse_fft(tmp) shift(tmp, 0, shift_width) return tmp | |
grate = y_grating(image.ydim, image.xdim) image.data *= grate | def run(self, image): | |
nifti.writeImage(image, outfile, data_type, 3, self.format[6:]) | nifti.writeImage(image, self.filename, data_type, 3, self.format[6:]) | def writeNifti(self, image): from imaging import nifti |
if nblocks == 1 and ntraces == nslice*n_pe: | if nblocks == nvol_true and ntraces == nslice*n_pe: | def _get_fidformat(self, fidfile): """ Determine fid format from the number of blocks per volumen and the number of traces per block. Known formats are: compressed uncompressed epi2fid asems_ncsnn asems_nccnn """ n_pe = self.n_pe n_pe_true = self.n_pe_true nslice = self.nslice nvol_true = self.nvol_true nblocks = fid... |
print "time_reverse = ",time_reverse | def loadData(self, datadir): """ This method reads the data from a fid file into following VarianData attributes: | |
print "time_rev= ",time_rev | def loadData(self, datadir): """ This method reads the data from a fid file into following VarianData attributes: | |
cmap=self.cmap, norm=norm, extent=(r_pts[0], r_pts[-1], 0, 1)) | cmap=self.cmap, norm=norm, aspect='auto', extent=(r_pts[0], r_pts[-1], 0, 1)) | def setRange(self, range, norm=None): self.norm = norm dMin, dMax = range ax = self.figure.axes[0] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.