def calculate(FD_add, E_add, T_add, result_name, unit): import time import os import pythoncom from mlab.releases import latest_release as matlab from matlab import matlabroot import win32com.client from win32com.client import Dispatch file_dir = Setting.FILR_DIR["MAP1_DIR"] result_name = os.path.join(file_dir, result_name + '.xls') # 结果数据的名字 #判断 文件名是否已存在 if os.path.exists(result_name): return "计算失败,主题重复,请修改主题!" print('调用开始!', time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))) pythoncom.CoInitialize() matlab.path(matlab.path(), os.path.join(Setting.BASE_DIR, "map1", "matrix")) # 设置路径 T_addList = T_add.split('\\') T_add_index = T_add.replace(T_addList[len(T_addList) - 1], '') h = Dispatch("Matlab.application") h.execute("matlab_3('" + FD_add + "','" + E_add + "','" + T_add + "','" + result_name + "','" + unit + "')") print('调用结束!', time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))) return result_name
def rawAnalyseSleep(workdir): progress = '[Task] raw sleep analysis of %s' % workdir matlab.path(matlab.path(), r'./matlab') # setup matlab env print progress emailProgress(progress, lRcvProgress) while(1): # configure light schedule isValid = False while(1): print '\tconfigure light schedule' isValid = configTime(workdir) if isValid: break # configure tube order isValid = False while(1): print '\tconfigure tube order' isValid = runConfigOrder(workdir) if isValid: break # start raw sleep analysis #try: matlab.batProcess() # call batchProcess.m #except(mlab.matlabcom.MatlabError): #print 'Invalid configuration. Please try again.' #continue break progress = '[Complete] raw sleep analysis of %s' % workdir print progress emailProgress(progress, lRcvProgress)
def registros(request): # Handle file upload if request.method == 'POST': form = RegistroEEGForm(request.POST, request.FILES) if form.is_valid(): time.sleep(1) instance = form.save(commit=False) pac = instance.paciente.id print pac assert type(pac) == int matlab.path(matlab.path(), 'D:\Registros') matlab.generarGrafica2(pac) directory = 'Pacientes/Paciente%s/Registro%s.png' % (pac, pac) instance.archivo_registro = directory form.save() render(request, "registros.html", {}) else: form = RegistroEEGForm() # A empty, unbound form # Load documents for the list page registros_eeg = RegistroEEG.objects.all() # Render list page with the documents and the form return render_to_response( 'registros.html', {'registros': registros_eeg, 'form': form}, context_instance=RequestContext(request) )
def registros(request): # Handle file upload if request.method == 'POST': form = RegistroEEGForm(request.POST, request.FILES) if form.is_valid(): time.sleep(1) instance = form.save(commit=False) pac = instance.paciente.id print pac assert type(pac) == int matlab.path(matlab.path(), 'D:\Registros') matlab.generarGrafica2(pac) directory = 'Pacientes/Paciente%s/Registro%s.png' % (pac, pac) instance.archivo_registro = directory form.save() render(request, "registros.html", {}) else: form = RegistroEEGForm() # A empty, unbound form # Load documents for the list page registros_eeg = RegistroEEG.objects.all() # Render list page with the documents and the form return render_to_response('registros.html', { 'registros': registros_eeg, 'form': form }, context_instance=RequestContext(request))
def fineAnalyseSleep(workdir): progress = '[Task] fine sleep analysis of %s' % workdir matlab.path(matlab.path(), r'./matlab') # setup matlab env print progress emailProgress(progress, lRcvProgress) configDeath('.') matlab.fineProcess() progress = '[Complete] fine sleep analysis of %s' % workdir print progress emailProgress(progress, lRcvProgress)
def renameDav(workdir): print '[Task] rename all dav files' matlab.path(matlab.path(), r'./matlab') try: matlab.renameDav() except(mlab.matlabcom.MatlabError): print 'no file has been renamed.' return progress = '\t[Complete] All dav files have been renamed;' print progress txt = 'workdir = %s\nprogress = %s\n' % (workdir, progress) emailProgress(txt, lRcvProgress)
def calculate(FD_add, E_add, T_add, result_name, unit): print('调用开始!', time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))) pythoncom.CoInitialize() print(matlabroot()) pwd = os.getcwd() matlab.path(matlab.path(), pwd) # 设置路径 print(matlab.path()) T_addList = T_add.split('\\') T_add_index = T_add.replace(T_addList[len(T_addList) - 1], '') result_name = T_add_index + result_name + '.xls' # 结果数据的名字 h = Dispatch("Matlab.application") h.execute("test8('" + FD_add + "','" + E_add + "','" + T_add + "','" + result_name + "')") #h.execute("matlab_3('"+FD_add+"','"+E_add+"','"+T_add+"','"+result_name+"')") print('调用结束!', time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))) return result_name
# -*- coding: utf-8 -*- """ Created on Sun May 26 09:08:53 2019 @author: ztidus """ # -*- coding: utf-8 -*- from mlab.releases import latest_release as matlab matlab.path(matlab.path(),r'/media/ztidus/new_disk/MATLAB/R2017b/bin/matlab') #设置路径 def mainFunction(): a = int(1) b = int(2) result = matlab.get_sum(a, b)# 调用matlab的函数 print(result) #======================================= if __name__ == '__main__': print('running...') mainFunction()
#!/usr/bin/env python import caffe from data_provider_layer import DataProvider import os import pdb import numpy as np import mlab from mlab.releases import latest_release as matlab matlab.path(matlab.path(),'/data1/qtang/samsung/wheels/matlab') def feat_extract(device_id=2, img_list_path='', batchsize=256, net='./deploy_lda_siamese.prototxt', model='./197_iter_500.caffemodel', iter=500 , blob='pool6'): f_path = './'+'feat_'+os.path.basename(img_list_path).split('.')[0]+'/iter'+str(iter)+'/'+blob if not os.path.exists(f_path): os.makedirs(f_path) dp = DataProvider(batchsize=batchsize, path=img_list_path) img_list_len=len(dp.img_dict) net = caffe.Net(net, model, caffe.TEST) caffe.set_device(device_id) caffe.set_mode_gpu() if blob == 'fc7_n': feature = np.zeros((batchsize*100,298)) else: feature = np.zeros((batchsize*100,8192)) img_name = [] block_label = [] index = 0 epoch = 0 counter = 1 while epoch==0: img_np, labels, epoch, img_name_batch = dp.get_batch_vec() net.blobs['top_0'].data[...] = img_np
#!/usr/bin/env python # encoding:utf-8 import pse import argparse from argparse import RawTextHelpFormatter from mlab.releases import latest_release as matlab from mlab.releases import latest_release as matlab from mlab.releases import latest_release as matlab from collections import OrderedDict import numpy as np import math matlab.path(matlab.path(), r'E:\Bioinformation\yq_aptamer\yq_aptamer_web\Pse-in-One-2.0' ) #设置路径,注意E:\python&matlab为放置MATLAB程序的路径 print "请输入适配体序列" path_aptamer = matlab.input_file_01( ) #调用自己定义的m函数就可以了,注意,这里的k3mer为自己定义的MATLAB函数,然后将结果赋给k3mer就好了。 print "请输入靶点序列" path_target = matlab.input_file_02( ) #调用自己定义的m函数就可以了,注意,这里的k3mer为自己定义的MATLAB函数,然后将结果赋给k3mer就好了。 # print path def read_biodata(data_file): ''' data_file是保存有生物序列的fasta格式的txt文件,并将它保存在字典中,原来的顺序保存在列表中 :param data_file: data_file是保存有生物序列的fasta格式的txt文件 :return:返回 ''' file = open(data_file)
#!/usr/bin/env python # encoding:utf-8 import pse import argparse from argparse import RawTextHelpFormatter from mlab.releases import latest_release as matlab from collections import OrderedDict matlab.path(matlab.path(),r'E:\Bioinformation\yq_aptamer\yq_aptamer_web\Pse-in-One-2.0') print "请输入适配体序列" path_aptamer = matlab.input_file_aptamer() print path_aptamer print "请输入靶点序列" path_target = matlab.input_file_target() print path_target # print path def read_biodata(data_file): ''' data_file是保存有生物序列的fasta格式的txt文件,并将它保存在字典中,原来的顺序保存在列表中 :param data_file: data_file是保存有生物序列的fasta格式的txt文件 :return:返回 ''' file = open(data_file) seq = {} list = [] i = 1; for line in file: if line[0] == ">": name = line.strip()[1:]