def _generate_setup(self): r""" Perform applicable preliminary checks and calculations required for generation """ self._Nx = 5 self._Ny = 5 self._Nz = 5 self._Lc = 1 self._Lx = sp.float16(self._Nx * self._Lc) self._Ly = sp.float16(self._Ny * self._Lc) self._Lz = sp.float16(self._Nz * self._Lc)
def _generate_setup(self): r""" Perform applicable preliminary checks and calculations required for generation """ self._Nx = 5 self._Ny = 5 self._Nz = 5 self._Lc = 1 self._Lx = sp.float16(self._Nx*self._Lc) self._Ly = sp.float16(self._Ny*self._Lc) self._Lz = sp.float16(self._Nz*self._Lc)
def find_clusters_from_3D(fnifti, thr): """ Function to use afni command line to find clusters from a 3D nifti. TODO(dhjelm): change this to use nipy functions. Parameters ---------- fnifti: nifti file Nifti file to process. thr: float Threshold used for clusters. Returns ------- cluster: a list of floats """ cmd = ("3dclust " "-1Dformat -quiet -nosum -2thresh -2 %.2f " "-dxyz=1 2 80 2>/dev/null" % thr) awk = "awk '{ print $1\"\t\"$2\"\t\"$3\"\t\"$4\"\t\"$5\"\t\"$6\"\t\"$11\"\t\"$14\"\t\"$15\"\t\"$16}'" cmdline = cmd + " '%s'| " % fnifti + awk proc = subprocess.Popen(cmdline, stdout=subprocess.PIPE, shell=True) (out, err) = proc.communicate() if "#**" in out.split(): return [] cluster = float16(out.split()) return cluster
def find_clusters_from_4D(fnifti, i, thr): """ Function to use afni command line to find clusters from a 4D nifti. TODO(dhjelm): change this to use nipy functions. Parameters ---------- fnifti: nifti file Nifti file to process. i: integer Index of the feature in the nifti file. thr: float Threshold used for clusters. Returns ------- clusters: list of tuples of floats List of 3d clusters. """ assert isinstance(i, int) assert isinstance(thr, (int, float)) cmd = ("3dclust " "-1Dformat -quiet -nosum -1dindex %d -1tindex %d -2thresh -2 %.2f " "-dxyz=1 2 80 2>/dev/null" % (i, i, thr)) awk = "awk '{ print $1\"\t\"$2\"\t\"$3\"\t\"$4\"\t\"$5\"\t\"$6\"\t\"$11\"\t\"$14\"\t\"$15\"\t\"$16}'" cmdline = cmd + " '%s'| " % fnifti + awk proc = subprocess.Popen(cmdline, stdout=subprocess.PIPE, shell=True) (out, err) = proc.communicate() if "#**" in out.split(): return [] clusters = float16(out.split()) return clusters