예제 #1
0
 def __init__(self, niipath, atlasobj, outfolder, json_name):
     self.niipath = niipath
     self.atlasobj = atlasobj
     self.atlas_3mm_path = atlasobj.volumes['3mm']['niifile']
     self.outfolder = outfolder
     self.exeName = path.fullfile("netcalc_intra_region.exe")
     self.from_json(json_name)
예제 #2
0
    def cb_button_Edit(self):
        """Edit the file.

        Use fileop.edit to launch the proper edit program, by file ext and file name.
        """
        filepath = self.value
        fileop.edit(path.fullfile(filepath))
예제 #3
0
 def open_configfile(self, configfile):
     configfile = path.fullfile(configfile)
     if not os.path.isfile(configfile):
         print('cannot open file {}'.format(configfile))
         return
     self.configfile_path = configfile
     configdict = load_json_ordered(configfile)
     self.load_configdict(configdict)
예제 #4
0
파일: job.py 프로젝트: yaojh18/mmdps
    def build_fullconfig(self):
        """Build full config.

		Search the config file using path.fullfile.
		"""
        config = path.fullfile(self.config)
        if config:
            return config
        else:
            return self.config
예제 #5
0
파일: toolman.py 프로젝트: yaojh18/mmdps
 def opentool(self, *argv):
     """Open the gui tool."""
     pyui = path.fullfile(self.pyui)
     assert pyui
     cmdlist = [pyui]
     if self.argv is not None:
         cmdlist.extend([self.argv])
     cmdlist.extend(argv)
     # print('opentool cmdlist: ', cmdlist)
     run.popen_py(cmdlist, sys.platform == 'win32')
예제 #6
0
def inter_calc():
    print(os.getcwd())
    corrcoef_path = os.path.join(os.getcwd(), 'bold_net', 'corrcoef.csv')
    outfolder = os.path.join(os.getcwd(), 'bold_net_attr_zzl')
    json_path = path.fullfile("inter_attr.json")
    print(outfolder)
    print(corrcoef_path)
    if not os.path.isdir(outfolder):
        os.mkdir(outfolder)
    inter_ac = InterAttrCalc(corrcoef_path, outfolder, json_path)
    inter_ac.calc()
예제 #7
0
 def open_configfile(self, configfile):
     configfile = path.fullfile(configfile)
     if not os.path.isfile(configfile):
         print('cannot open file {}'.format(configfile))
         return
     self.configfile_path = configfile
     configdict = load_json_ordered(configfile)
     self.rootfield = self.connector.config_to_field(configdict)
     self.mainfieldwidget = self.rootfield.build_widget(self.mainframe)
     self.set_mainwidget(self.mainfieldwidget)
     self.mainfieldwidget.pack()
예제 #8
0
def inter_calc_dynamic():
	# print(os.getcwd())
	corrcoef_path = os.path.join(os.getcwd(),'bold_net')
	nii_path = os.path.join(path.curparent(), 'pBOLD.nii')
	outfolder = os.path.join(os.getcwd(), OUTFOLDER_INTER)
	json_path = path.fullfile("inter_attr_dynamic.json")
	# print(outfolder)
	# print(corrcoef_path)
	if not os.path.isdir(outfolder):
		os.mkdir(outfolder)
	inter_ac = InterAttrCalcDynamic(nii_path,corrcoef_path,outfolder,json_path)
	inter_ac.calc()
예제 #9
0
파일: job.py 프로젝트: yaojh18/mmdps
    def build_fullcmd(self):
        """Build full command.

		If the cmd is not absolute path, search in path for this cmd.
		It is similar to matlabpath, so you do not need to specify the
		full cmd path. Just make sure to avoid name clash.
		"""
        cmd = path.fullfile(self.cmd)
        if cmd:
            return cmd
        else:
            return self.cmd
예제 #10
0
def intra_calc():
    print(os.getcwd())
    atlasobj = path.curatlas()
    volumename = '3mm'

    nii_path = os.path.join(path.curparent(), 'pBOLD.nii')
    outfolder = os.path.join(os.getcwd(), 'bold_net_attr_zzl')
    json_path = path.fullfile("intra_attr.json")
    print(nii_path)
    print(outfolder)
    if not os.path.isdir(outfolder):
        os.mkdir(outfolder)
    intra_ac = IntraAttrCalc(nii_path, atlasobj, outfolder, json_path)
    intra_ac.calc()
예제 #11
0
def intra_calc_dynamic():
	# print(os.getcwd())
	atlasobj = path.curatlas()
	volumename = '3mm'

	nii_path = os.path.join(path.curparent(), 'pBOLD.nii')
	outfolder = os.path.join(os.getcwd(), OUTFOLDER_INTRA)
	json_path = path.fullfile("intra_attr_dynamic.json")
	# print(nii_path)
	# print(outfolder)
	if not os.path.isdir(outfolder):
		os.mkdir(outfolder)
	intra_ac = IntraAttrCalcDynamic(nii_path,atlasobj,outfolder,json_path)
	intra_ac.calc()
예제 #12
0
파일: para.py 프로젝트: yaojh18/mmdps
    def run(self):
        """Run the para.
		finalfolders is the constructed folder in which to run the job in parallel,
		Or sequential if configured that way.
		Env MMDPS_NEWLIST_TXT will override folderlist.
		Env MMDPS_SECONDLIST_TXT will override secondlist.
		"""
        if self.folderlist == 'listdir':
            originalfolders = path.clean_listdir(self.mainfolder)
        else:
            originalfolders = loadsave.load_txt(
                path.env_override(self.folderlist, 'MMDPS_NEWLIST_TXT'))
        folders = [os.path.join(self.mainfolder, f) for f in originalfolders]
        if self.bsecond:
            finalfolders = []
            if type(self.secondlist) is list:
                secondfolders = self.secondlist
            elif self.secondlist == 'all':
                secondfolders = loadsave.load_txt(
                    os.path.join(rootconfig.path.atlas, 'atlas_list.txt'))
            else:
                secondfolders = loadsave.load_txt(
                    path.env_override(self.secondlist, 'MMDPS_SECONDLIST_TXT'))
            for folder in folders:
                for secondfolder in secondfolders:
                    newfolder = os.path.join(folder, secondfolder)
                    path.makedirs(newfolder)
                    finalfolders.append(newfolder)
        else:
            finalfolders = folders
        currentJob = job.create_from_dict(
            loadsave.load_json(path.fullfile(self.jobconfig)))
        if self.runmode == 'FirstOnly':
            return self.run_seq(currentJob, finalfolders[0:1])
        if self.runmode == 'Parallel':
            return self.run_para(currentJob, finalfolders)
        if self.runmode == 'Sequential':
            return self.run_seq(currentJob, finalfolders)
        else:
            print('Error: no such runmode as', self.runmode)
            return None
예제 #13
0
 def __init__(self, corrPath, outfolder, json_name):
     self.corrPath = corrPath
     self.outfolder = outfolder
     self.exeName = path.fullfile("netcalc_inter_region.exe")
     self.from_json(json_name)
예제 #14
0
"""Run a Para."""

import sys
import argparse
from mmdps.proc import para
from mmdps.util.loadsave import load_json
from mmdps.util import path

if __name__ == '__main__':
	parser = argparse.ArgumentParser()
	parser.add_argument('--config', help='para config json file', required=True)
	args = parser.parse_args()
	configpath = path.fullfile(args.config)
	print('Runpara: configpath', configpath)
	configDict = load_json(configpath)
	currentPara = para.load(configDict)
	currentPara.run()
	sys.stdin.close()
	sys.stdout.close()
	sys.stderr.close()
예제 #15
0
		# print(self.get_total_time_points())
		for start in range(0, self.get_total_time_points()-self.windowLength+1, self.stepSize):
			ts = self.gen_timeseries(start)
			if ts is None:
				# print(start,)
				raise Exception('Dynamic sliding window exceeds total time points')
			save_csvmat(self.outpath('timeseries-%d-%d.csv' % (start, start+self.windowLength)), ts)
			tscorr = np.corrcoef(ts)
			save_csvmat(self.outpath('corrcoef-%d-%d.csv' % (start, start+self.windowLength)), tscorr)

	def run(self):
		self.gen_net()

if __name__=="__main__":
	atlasobj = path.curatlas()
	volumename = '3mm'
	img = load_nii(os.path.join(path.curparent(), 'pBOLD.nii'))


	json_path = path.fullfile("inter_attr_dynamic.json")
	argsDict = load_json(json_path)	
	outfolder = os.path.join(os.getcwd(),'bold_net','dynamic_'+str(argsDict['stepSize'])+"_"+str(argsDict['windowLength']))
	os.makedirs(outfolder, exist_ok = True)
	# c = Calc(atlasobj, volumename, img, outfolder)
	# c.run()
	# atlasobj, volumename, img, outfolder, windowLength = 100, stepSize = 3
	# print(outfolder)
	# print(volumename)
	cal = Calc(atlasobj = atlasobj, volumename = volumename, img = img, outfolder = outfolder,windowLength=argsDict['windowLength'],stepSize=argsDict['stepSize'])
	cal.run()
예제 #16
0
파일: runjob.py 프로젝트: yaojh18/mmdps
"""Run a job."""

import sys, os
import argparse
from mmdps.proc import job
from mmdps.util import loadsave
from mmdps.util import path

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--config', help='job config json file', required=True)
    parser.add_argument('--folder',
                        help='job run in this folder',
                        default=None)
    args = parser.parse_args()
    print('Runjob Folder:', args.folder)
    configfile = path.fullfile(args.config)
    print('Runjob File:', configfile)
    configdict = loadsave.load_json(configfile)
    currentJob = job.create_from_dict(configdict)
    job.runjob(currentJob, args.folder)
    sys.stdin.close()
    sys.stdout.close()
    sys.stderr.close()
예제 #17
0
	def __init__(self, niipath, corrPath, outfolder, json_name ):
		self.niipath = niipath
		self.outfolder = outfolder
		self.exeName = path.fullfile("netcalc_inter_region_dynamic.exe")
		self.from_json(json_name)
		self.corrPath = corrPath+ "\\" +"dynamic_"+str(self.argsDict['stepSize'])+"_"+str(self.argsDict['windowLength'])+"\\"