本文整理汇总了Python中thunder.ThunderContext.start方法的典型用法代码示例。如果您正苦于以下问题:Python ThunderContext.start方法的具体用法?Python ThunderContext.start怎么用?Python ThunderContext.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类thunder.ThunderContext
的用法示例。
在下文中一共展示了ThunderContext.start方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: open
# 需要导入模块: from thunder import ThunderContext [as 别名]
# 或者: from thunder.ThunderContext import start [as 别名]
stimulus_pulse = 1
if stimulus_pulse == 1:
stimulus_on_time = [10,28,47,65,83,101]
stimulus_off_time = [14,32,51,69,87,105]
color_mat = ['#00FFFF','#0000A0','#800080','#FF00FF', '#800000','#A52A2A']
# Go into the main function that does pca for indiviudal trials
from pca_thunder_analysis import run_analysis_individualodors
from pca_thunder_analysis import run_analysis_eachodor
from pca_thunder_analysis import run_analysis_allodor
from thunder import ThunderContext
print 'Starting Thunder Now. Check console for details'
tsc = ThunderContext.start(appName="thunderpca")
if files_to_do_PCA[0]== 1:
run_analysis_individualodors(Exp_Folder, filename_save_prefix_forPCA, filename_save_prefix_for_textfile, pca_components_ind, num_pca_colors_ind, num_samples_ind, thresh_pca_ind, color_map_ind,\
tsc,redo_pca,reconstruct_pca, stimulus_on_time, stimulus_off_time,color_mat,required_pcs,time_baseline )
if files_to_do_PCA[1]== 1:
run_analysis_eachodor(Exp_Folder, filename_save_prefix_forPCA, filename_save_prefix_for_textfile, pca_components_eachodor, num_pca_colors_eachodor, num_samples_eachodor, thresh_pca_eachodor, color_map_eachodor,\
tsc,redo_pca,reconstruct_pca, stimulus_on_time, stimulus_off_time,color_mat,required_pcs,time_baseline )
if files_to_do_PCA[2]== 1:
run_analysis_allodor(Exp_Folder, filename_save_prefix_forPCA, filename_save_prefix_for_textfile, pca_components_allodor, num_pca_colors_allodor, num_samples_allodor, thresh_pca_allodor, color_map_allodor,\
tsc,redo_pca,reconstruct_pca, stimulus_on_time, stimulus_off_time,color_mat,required_pcs,time_baseline )
############# Save all imput parameters
with open(Exp_Folder+filename_save_prefix_forPCA+'_save_pca_variables', 'w') as f:
pickle.dump([pca_components_ind, num_pca_colors_ind, num_samples_ind, thresh_pca_ind, color_map_ind,\
示例2: Exception
# 需要导入模块: from thunder import ThunderContext [as 别名]
# 或者: from thunder.ThunderContext import start [as 别名]
"""
Example standalone app for mass-univariate regression
"""
import optparse
from thunder import ThunderContext, RegressionModel
if __name__ == "__main__":
parser = optparse.OptionParser(description="fit a regression model",
usage="%prog datafile modelfile outputdir [options]")
parser.add_option("--regressmode", choices=("mean", "linear", "bilinear"),
default="linear", help="form of regression")
opts, args = parser.parse_args()
try:
datafile = args[0]
modelfile = args[1]
outputdir = args[2]
except IndexError:
parser.print_usage()
raise Exception("too few arguments")
tsc = ThunderContext.start(appName="regress")
data = tsc.loadText(datafile)
result = RegressionModel.load(modelfile, opts.regressmode).fit(data)
outputdir += "-regress"
tsc.export(result.select('stats'), outputdir, "stats", "matlab")
tsc.export(result.select('betas'), outputdir, "betas", "matlab")
示例3: execute
# 需要导入模块: from thunder import ThunderContext [as 别名]
# 或者: from thunder.ThunderContext import start [as 别名]
def execute(self, lock, pipe):
"""
Execute this pull request
"""
lock.acquire()
base, module = self.clone()
f = open(base + 'info.json', 'r')
info = json.loads(f.read())
printer.status("Executing pull request %s from user %s"
% (self.id, self.login))
printer.status("Branch name: %s" % self.branch)
printer.status("Algorithm name: %s" % info['algorithm'])
sys.path.append(module)
run = importlib.import_module('run', module)
spark_home = os.getenv('SPARK_HOME')
if spark_home is None or spark_home == '':
raise Exception('must assign the environmental variable SPARK_HOME with the location of Spark')
sys.path.append(os.path.join(spark_home, 'python'))
sys.path.append(os.path.join(spark_home, 'python/lib/py4j-0.8.2.1-src.zip'))
with quiet():
from thunder import ThunderContext
from thunder.utils.launch import findThunderEgg
tsc = ThunderContext.start(master=self.get_master(), appName="neurofinder")
tsc.addPyFile(findThunderEgg())
log4j = tsc._sc._jvm.org.apache.log4j
log4j.LogManager.getRootLogger().setLevel(log4j.Level.ERROR)
time.sleep(5)
base_path = 'neuro.datasets.private/challenges/neurofinder.test'
datasets = ['00.00.test', '00.01.test', '01.00.test', '01.01.test',
'02.00.test', '02.01.test', '03.00.test']
metrics = {'score': [], 'recall': [], 'precision': [], 'overlap': [], 'exactness': []}
try:
for ii, name in enumerate(datasets):
printer.status("Proccessing data set %s" % name)
data_path = 's3n://' + base_path + '/' + name
data_info = self.load_info(base_path, name)
data = tsc.loadImages(data_path + '/images/', recursive=True,
npartitions=600)
truth = tsc.loadSources(data_path + '/sources/sources.json')
sources = run.run(data, info=data_info)
threshold = 6.0 / data_info['pixels-per-micron']
recall, precision, score = truth.similarity(sources, metric='distance', minDistance=threshold)
stats = truth.overlap(sources, method='rates', minDistance=threshold)
if sum(~isnan(stats)) > 0:
overlap, exactness = tuple(nanmean(stats, axis=0))
else:
overlap, exactness = 0.0, 1.0
contributors = str(", ".join(data_info["contributors"]))
animal = data_info["animal"]
region = data_info["region"]
lab = data_info["lab"]
base = {"dataset": name, "contributors": contributors,
"lab": lab, "region": region, "animal": animal}
m = {"value": score}
m.update(base)
metrics['score'].append(m)
m = {"value": recall}
m.update(base)
metrics['recall'].append(m)
m = {"value": precision}
m.update(base)
metrics['precision'].append(m)
m = {"value": overlap}
m.update(base)
metrics['overlap'].append(m)
m = {"value": exactness}
m.update(base)
metrics['exactness'].append(m)
base = data.mean()
im = sources.masks(outline=True, base=base.clip(0, percentile(base, 99.9)))
self.post_image(im, name)
for k in metrics.keys():
overall = mean([v['value'] for v in metrics[k]])
metrics[k].append({"dataset": "overall", "value": overall,
"contributors": "", "region": "", "animal": ""})
msg = "Execution successful"
#.........这里部分代码省略.........
示例4: Exception
# 需要导入模块: from thunder import ThunderContext [as 别名]
# 或者: from thunder.ThunderContext import start [as 别名]
"""
Example standalone app for calculating series statistics
"""
import optparse
from thunder import ThunderContext
if __name__ == "__main__":
parser = optparse.OptionParser(description="compute summary statistics on time series data",
usage="%prog datafile outputdir mode [options]")
parser.add_option("--preprocess", action="store_true", default=False)
opts, args = parser.parse_args()
try:
datafile = args[0]
outputdir = args[1]
mode = args[2]
except IndexError:
parser.print_usage()
raise Exception("too few arguments")
tsc = ThunderContext.start(appName="stats")
data = tsc.loadSeries(datafile).cache()
vals = data.seriesStat(mode)
outputdir += "-stats"
tsc.export(vals, outputdir, "stats_" + mode, "matlab")
示例5: Exception
# 需要导入模块: from thunder import ThunderContext [as 别名]
# 或者: from thunder.ThunderContext import start [as 别名]
from thunder import ThunderContext, RegressionModel, PCA
if __name__ == "__main__":
parser = optparse.OptionParser(description="fit a regression model",
usage="%prog datafile modelfile outputdir [options]")
parser.add_option("--regressmode", choices=("mean", "linear", "bilinear"), help="form of regression")
parser.add_option("--k", type=int, default=2)
opts, args = parser.parse_args()
try:
datafile = args[0]
modelfile = args[1]
outputdir = args[2]
except IndexError:
parser.print_usage()
raise Exception("too few arguments")
tsc = ThunderContext.start(appName="regresswithpca")
data = tsc.loadSeries(datafile)
model = RegressionModel.load(modelfile, opts.regressmode) # do regression
betas, stats, resid = model.fit(data)
pca = PCA(opts.k).fit(betas) # do PCA
traj = model.fit(data, pca.comps) # get trajectories
outputdir += "-regress"
tsc.export(pca.comps, outputdir, "comps", "matlab")
tsc.export(pca.latent, outputdir, "latent", "matlab")
tsc.export(pca.scores, outputdir, "scores", "matlab")
tsc.export(traj, outputdir, "traj", "matlab")
示例6: execute
# 需要导入模块: from thunder import ThunderContext [as 别名]
# 或者: from thunder.ThunderContext import start [as 别名]
def execute(self):
"""
Execute this pull request
"""
printer.status("Executing pull request %s from user %s" % (self.id, self.login))
base, module = self.clone()
f = open(base + 'info.json', 'r')
info = json.loads(f.read())
sys.path.append(module)
run = importlib.import_module('run')
spark = os.getenv('SPARK_HOME')
if spark is None or spark == '':
raise Exception('must assign the environmental variable SPARK_HOME with the location of Spark')
sys.path.append(os.path.join(spark, 'python'))
sys.path.append(os.path.join(spark, 'python/lib/py4j-0.8.2.1-src.zip'))
from thunder import ThunderContext
tsc = ThunderContext.start(master="local", appName="neurofinder")
datasets = ['data-0', 'data-1', 'data-2', 'data-3', 'data-4', 'data-5']
centers = [5, 7, 9, 11, 13, 15]
metrics = {'accuracy': [], 'overlap': [], 'distance': [], 'count': [], 'area': []}
try:
for ii, name in enumerate(datasets):
data, ts, truth = tsc.makeExample('sources', dims=(200, 200),
centers=centers[ii], noise=1.0, returnParams=True)
sources = run.run(data)
accuracy = truth.similarity(sources, metric='distance', thresh=10, minDistance=10)
overlap = truth.overlap(sources, minDistance=10)
distance = truth.distance(sources, minDistance=10)
count = sources.count
area = mean(sources.areas)
metrics['accuracy'].append({"dataset": name, "value": accuracy})
metrics['overlap'].append({"dataset": name, "value": nanmean(overlap)})
metrics['distance'].append({"dataset": name, "value": nanmean(distance)})
metrics['count'].append({"dataset": name, "value": count})
metrics['area'].append({"dataset": name, "value": area})
im = sources.masks(base=data.mean())
self.post_image(im, name)
for k in metrics.keys():
overall = mean([v['value'] for v in metrics[k]])
metrics[k].append({"dataset": "overall", "value": overall})
msg = "Execution successful"
printer.success()
self.update_status("executed")
except Exception:
metrics = None
msg = "Execution failed"
printer.error("failed, returning error")
print(traceback.format_exc())
self.send_message(msg)
return metrics, info
示例7: open
# 需要导入模块: from thunder import ThunderContext [as 别名]
# 或者: from thunder.ThunderContext import start [as 别名]
if use_existing_parameters == 1:
with open(Exp_Folder+filename_save_prefix_forICA+'_save_ICA_variables') as f:
ICA_components_ind, num_ICA_colors_ind, color_map_ind,\
ICA_components_eachexp, num_ICA_colors_eachexp, color_map_eachexp,\
ICA_components_allexp, num_ICA_colors_allexp, color_map_allexp,colors_ica = pickle.load(f)
# Go into the main function that does ICA for indiviudal trials
from ica_thunder_analysis import run_analysis_individualexps
from ica_thunder_analysis import run_analysis_eachexp
from ica_thunder_analysis import run_analysis_allexp
from thunder import ThunderContext
print 'Starting Thunder Now. Check console for details'
tsc = ThunderContext.start(appName="thunderICA")
if files_to_do_ICA[0]== 1:
run_analysis_individualexps(Exp_Folder, filename_save_prefix_forICA, filename_save_prefix_for_textfile, ICA_components_ind, PCA_components_ind, num_ICA_colors_ind, color_map_ind,\
tsc,redo_ICA, num_fish_used, stimulus_pulse, stimulus_on_time, stimulus_off_time,color_mat, time_baseline,colors_ica )
if files_to_do_ICA[1]== 1:
run_analysis_eachexp(Exp_Folder, filename_save_prefix_forICA, filename_save_prefix_for_textfile, ICA_components_eachexp, PCA_components_eachexp, num_ICA_colors_eachexp, color_map_eachexp,\
tsc,redo_ICA, num_fish_used, stimulus_pulse, stimulus_on_time, stimulus_off_time,color_mat, time_baseline,colors_ica )
if files_to_do_ICA[2]== 1:
run_analysis_allexp(Exp_Folder, filename_save_prefix_forICA, filename_save_prefix_for_textfile, ICA_components_allexp, PCA_components_allexp, num_ICA_colors_allexp, color_map_allexp,\
tsc,redo_ICA, num_fish_used, stimulus_pulse, stimulus_on_time, stimulus_off_time,color_mat, time_baseline,colors_ica )
############# Save all imput parameters
with open(Exp_Folder+filename_save_prefix_forICA+'_save_ICA_variables', 'w') as f:
示例8: open
# 需要导入模块: from thunder import ThunderContext [as 别名]
# 或者: from thunder.ThunderContext import start [as 别名]
color_mat = ['#00FFFF','#0000A0','#800080','#FF00FF', '#800000','#A52A2A']
if use_existing_parameters == 1:
with open(Exp_Folder+filename_save_prefix+'_save_kmeans_variables') as f:
kmeans_clusters_ind, kmeans_clusters_eachodor, kmeans_clusters_allodor, time_baseline,ignore_clusters = pickle.load(f)
# Go into the main function that does kmeans for indiviudal trials
from kmeans_thunder_analysis import run_analysis_individualodors
from kmeans_thunder_analysis import run_analysis_eachodor
from kmeans_thunder_analysis import run_analysis_allodor
from thunder import ThunderContext
print 'Starting Thunder Now. Check console for details'
tsc = ThunderContext.start(appName="thunderkmeans")
if files_to_do_kmeans[0]== 1:
run_analysis_individualodors(Exp_Folder, filename_save_prefix, filename_save_prefix_forkmeanswithPCA, kmeans_clusters_ind,\
stimulus_on_time, stimulus_off_time, tsc,redo_kmeans,time_baseline,redo_kmeans_colormap,ignore_clusters)
if files_to_do_kmeans[1]== 1:
run_analysis_eachodor(Exp_Folder, filename_save_prefix, filename_save_prefix_forkmeanswithPCA, kmeans_clusters_eachodor, \
stimulus_on_time, stimulus_off_time, tsc,redo_kmeans,time_baseline,redo_kmeans_colormap,ignore_clusters)
if files_to_do_kmeans[2]== 1:
run_analysis_allodor(Exp_Folder, filename_save_prefix, filename_save_prefix_forkmeanswithPCA, kmeans_clusters_allodor, \
stimulus_on_time, stimulus_off_time, tsc,redo_kmeans, time_baseline,redo_kmeans_colormap,ignore_clusters)
############# Save all imput parameters
with open(Exp_Folder+filename_save_prefix+'_save_kmeans_variables', 'w') as f:
示例9: int
# 需要导入模块: from thunder import ThunderContext [as 别名]
# 或者: from thunder.ThunderContext import start [as 别名]
from thunder import ThunderContext, ICA, export
if __name__ == "__main__":
parser = optparse.OptionParser(description="do independent components analysis",
usage="%prog datafile outputdir k c [options]")
parser.add_option("--svdmethod", choices=("direct", "em"), default="direct")
parser.add_option("--maxiter", type=float, default=100)
parser.add_option("--tol", type=float, default=0.000001)
parser.add_option("--seed", type=int, default=0)
opts, args = parser.parse_args()
try:
datafile = args[0]
outputdir = args[1]
k = int(args[2])
c = int(args[3])
except IndexError:
parser.print_usage()
raise Exception("too few arguments")
tsc = ThunderContext.start(appName="ica")
data = tsc.loadSeries(datafile).cache()
model = ICA(k=k, c=c, svdmethod=opts.svdmethod, maxiter=opts.maxiter, tol=opts.tol, seed=opts.seed)
result = model.fit(data)
outputdir += "-ica"
export(result.a, outputdir, "a", "matlab")
export(result.sigs, outputdir, "sigs", "matlab")
示例10: int
# 需要导入模块: from thunder import ThunderContext [as 别名]
# 或者: from thunder.ThunderContext import start [as 别名]
usage="%prog datafile outputdir k [options]")
parser.add_option("--nmfmethod", choices=["als"], default="als")
parser.add_option("--maxiter", type=float, default=20)
parser.add_option("--tol", type=float, default=0.001)
parser.add_option("--w_hist", action="store_true", default=False)
parser.add_option("--recon_hist", action="store_true", default=False)
opts, args = parser.parse_args()
try:
datafile = args[0]
outputdir = args[1]
k = int(args[2])
except IndexError:
parser.print_usage()
raise Exception("too few arguments")
tsc = ThunderContext.start(appName="nmf")
data = tsc.loadSeries(datafile).cache()
nmf = NMF(k=k, method=opts.nmfmethod, maxIter=opts.maxiter, tol=opts.tol,
wHist=opts.w_hist, reconHist=opts.recon_hist)
nmf.fit(data)
outputdir += "-nmf"
tsc.export(nmf.w, outputdir, "w", "matlab")
tsc.export(nmf.h, outputdir, "h", "matlab")
if opts.w_hist:
tsc.export(nmf.wConvergence, outputdir, "w_convergence", "matlab")
if opts.recon_hist:
tsc.export(nmf.reconErr, outputdir, "rec_err", "matlab")
示例11:
# 需要导入模块: from thunder import ThunderContext [as 别名]
# 或者: from thunder.ThunderContext import start [as 别名]
Exp_Folder ='/Users/seetha/Desktop/Ruey_Habenula/Habenula/Short_Stimulus/Fish104_Block2_Blue&UV1c/'
filename_save_prefix = 'Test1'
from thunder import ThunderContext
print 'Starting Thunder Now. Check console for details'
tsc = ThunderContext.start(appName="thunderNMF")
import os
filesep = os.path.sep
import matplotlib.pyplot as plt
import numpy as np
from thunder_NMF import run_NMF
from thunder_NMF import make_NMF_maps
from thunder_NMF_plots import plot_NMF_maps
from thunder import Colorize
image = Colorize.image
Stimulus_Directories = [f for f in os.listdir(Exp_Folder) if os.path.isdir(os.path.join(Exp_Folder, f)) and f.find('Figures')<0]
#Stimulus_Directories
ii = 0
Trial_Directories = [f for f in os.listdir(os.path.join(Exp_Folder, Stimulus_Directories[ii]))\
if os.path.isdir(os.path.join(Exp_Folder, Stimulus_Directories[ii], f)) and f.find('Figures')<0]
Trial_Directories
jj = 0
stim_start = 10 #Stimulus Starting time point
stim_end = 14 #Stimulus Ending time point