Exemple #1
0
def somefunc(exp_prep):
    # print(f"\n{'-' * 5} RUNNING PRE4AP TRIALS {'-' * 5}")
    prep = exp_prep[:-6]
    pre4aptrial = exp_prep[-5:]
    expobj, _ = aoutils.import_expobj(prep=prep,
                                      trial=pre4aptrial,
                                      verbose=False)
    return expobj
Exemple #2
0
    def inner(*args, **kwargs):
        def somefunc(exp_prep):
            pass

        for exp_prep in pj.flattenOnce(allopticalResults.post_4ap_trials):
            prep = exp_prep[:-6]
            pre4aptrial = exp_prep[-5:]
            expobj, _ = aoutils.import_expobj(prep=prep,
                                              trial=pre4aptrial,
                                              verbose=False)
            aoutils.working_on(expobj)
            res_ = func(expobj=expobj, **kwargs)
            aoutils.end_working_on(expobj)

        # with concurrent.futures.ThreadPoolExecutor() as executor:
        #     trials = pj.flattenOnce(allopticalResults.post_4ap_trials)
        #     executor.map(somefunc, trials)
        #     # _ = [executor.submit(somefunc, exp_prep) for exp_prep in trials]

        t_end = time.time()
        pj.timer(t_start, t_end)
        print(f" {'--' * 5} COMPLETED FOR LOOP ACROSS EXPS {'--' * 5}\n")
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

import alloptical_utils_pj as aoutils
import alloptical_plotting_utils as aoplot
from funcsforprajay import funcs as pj

from skimage import draw

# # import results superobject that will collect analyses from various individual experiments
results_object_path = '/home/pshah/mnt/qnap/Analysis/alloptical_results_superobject.pkl'
allopticalResults = aoutils.import_resultsobj(pkl_path=results_object_path)

expobj, experiment = aoutils.import_expobj(prep='RL109', trial='t-013')
"""######### ZONE FOR CALLING THIS SCRIPT DIRECTLY FROM THE SSH SERVER ###########
######### ZONE FOR CALLING THIS SCRIPT DIRECTLY FROM THE SSH SERVER ###########
######### ZONE FOR CALLING THIS SCRIPT DIRECTLY FROM THE SSH SERVER ###########
######### ZONE FOR CALLING THIS SCRIPT DIRECTLY FROM THE SSH SERVER ###########
######### ZONE FOR CALLING THIS SCRIPT DIRECTLY FROM THE SSH SERVER ###########
######### ZONE FOR CALLING THIS SCRIPT DIRECTLY FROM THE SSH SERVER ###########
######### ZONE FOR CALLING THIS SCRIPT DIRECTLY FROM THE SSH SERVER ###########
######### ZONE FOR CALLING THIS SCRIPT DIRECTLY FROM THE SSH SERVER ###########
######### ZONE FOR CALLING THIS SCRIPT DIRECTLY FROM THE SSH SERVER ###########
"""

# sys.exit()
"""# ########### END OF // ZONE FOR CALLING THIS SCRIPT DIRECTLY FROM THE SSH SERVER ###########
########### END OF // ZONE FOR CALLING THIS SCRIPT DIRECTLY FROM THE SSH SERVER ###########
########### END OF // ZONE FOR CALLING THIS SCRIPT DIRECTLY FROM THE SSH SERVER ###########
Exemple #4
0
from skimage import draw

# import results superobject that will collect analyses from various individual experiments
results_object_path = '/home/pshah/mnt/qnap/Analysis/alloptical_results_superobject.pkl'
allopticalResults = aoutils.import_resultsobj(pkl_path=results_object_path)

results_object_path = '/home/pshah/mnt/qnap/Analysis/onePstim_results_superobject.pkl'
onePresults = aoutils.import_resultsobj(pkl_path=results_object_path)

save_path_prefix = '/home/pshah/mnt/qnap/Analysis/Procesing_figs/sz_processing_boundaries_2022-01-06/'
os.makedirs(save_path_prefix) if not os.path.exists(save_path_prefix) else None

# %% 5.0-dc) ANALYSIS: cross-correlation between mean FOV 2p calcium trace and LFP seizure trace TODO
import scipy.signal as signal

expobj, experiment = aoutils.import_expobj(prep='RL109', trial='t-017')

sznum = 1
slice = np.s_[
    expobj.convert_frames_to_paqclock(expobj.seizure_lfp_onsets[sznum]):expobj.
    convert_frames_to_paqclock(expobj.seizure_lfp_offsets[sznum])]

# detrend
detrended_lfp = signal.detrend(
    expobj.lfp_signal[expobj.frame_start_time_actual:expobj.
                      frame_end_time_actual])[slice] * -1

# downsample LFP signal to the same # of datapoints as # of frames in 2p calcium trace
CaUpsampled1 = signal.resample(expobj.meanRawFluTrace,
                               len(detrended_lfp))[slice]
import alloptical_utils_pj as aoutils
import alloptical_plotting_utils as aoplot
from funcsforprajay import funcs as pj
import tifffile as tf
from skimage.transform import resize
from mpl_toolkits import mplot3d

# import results superobject that will collect analyses from various individual experiments
results_object_path = '/home/pshah/mnt/qnap/Analysis/alloptical_results_superobject.pkl'
allopticalResults = aoutils.import_resultsobj(pkl_path=results_object_path)

save_path_prefix = '/home/pshah/mnt/qnap/Analysis/Results_figs/Nontargets_responses_2021-11-11'
os.makedirs(save_path_prefix) if not os.path.exists(save_path_prefix) else None

expobj, experiment = aoutils.import_expobj(
    aoresults_map_id='post e.1'
)  # PLACEHOLDER IMPORT OF EXPOBJ TO MAKE THE CODE WORK

# %% 1) SEIZURE WAVEFRONT PLOTTING AND ANALYSIS
"""################################# SEIZURE EVENTS PLOTTING ##############################################################
########################################################################################################################

# PLOT HEATMAP of SEIZURE EVENTS
"""
sz = 2
sz_onset, sz_offset = expobj.stims_bf_sz[sz], expobj.stims_af_sz[sz + 1]

# -- approach of dFF normalize to the mean of the Flu data 2 seconds before the seizure
pre_sz = 2 * int(expobj.fps)
sz_flu = expobj.raw[[expobj.cell_id.index(cell) for cell in expobj.good_cells],
                    sz_onset - pre_sz:sz_offset]
Exemple #6
0
    matlab_pairedmeasurements_path=matlab_pairedmeasurement_path,
    processed_tiffs=False,
    discard_all=True,
    analysis_save_path=analysis_save_path)

# %% 2) ### the below is usually run from jupyter notebooks dedicated to each experiment prep.
to_suite2p = [
    't-002', 't-006', 't-007', 't-008', 't-009', 't-011', 't-016', 't-017'
]  # specify all trials that were used in the suite2p runtotal_frames_stitched = 0
baseline_trials = ['t-002',
                   't-006']  # specify which trials to use as spont baseline
# note ^^^ this only works currently when the spont baseline trials all come first, and also back to back

trials = ['t-011']

for trial in trials:
    ###### IMPORT pkl file containing expobj
    pkl_path = "/home/pshah/mnt/qnap/Analysis/%s/%s/%s_%s/%s_%s.pkl" % (
        date, animal_prep, date, trial, date, trial)

    expobj, experiment = aoutils.import_expobj(trial=trial,
                                               date=date,
                                               pkl_path=pkl_path,
                                               do_processing=False)
    expobj.s2p_path = '/home/pshah/mnt/qnap/Analysis/%s/suite2p/alloptical-2p-1_25x-alltrials/plane0' % date
    aoutils.run_alloptical_processing_photostim(
        expobj,
        to_suite2p=to_suite2p,
        baseline_trials=baseline_trials,
        force_redo=True)
Exemple #7
0
from funcsforprajay import funcs as pj

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns


# # import results superobject that will collect analyses from various individual experiments
results_object_path = '/home/pshah/mnt/qnap/Analysis/alloptical_results_superobject.pkl'
allopticalResults = aoutils.import_resultsobj(pkl_path=results_object_path)


# %% IMPORT expobj
# expobj, experiment = aoutils.import_expobj(aoresults_map_id='pre h.0')
expobj, experiment = aoutils.import_expobj(prep='RL109', trial='t-017')


# %% useful general plots

# aoplot.plotMeanRawFluTrace(expobj=expobj, stim_span_color=None, x_axis='Time', figsize=(20,3))

fig, axs = plt.subplots(2, 1, figsize=(20, 6))
fig, ax = aoplot.plotMeanRawFluTrace(expobj=expobj, stim_span_color=None, x_axis='frames', fig=fig, ax=axs[0], show=False)
fig, ax = aoplot.plotLfpSignal(expobj=expobj, stim_span_color='', x_axis='time', fig=fig, ax=axs[1], show=False)
fig.show()

aoplot.plot_SLMtargets_Locs(expobj=expobj, background=expobj.meanFluImg_registered)
aoplot.plot_lfp_stims(expobj=expobj, x_axis='Time')

expobj.plot_single_frame_tiff(frame_num=10040)
# NOTE: NEED TO RERUN FOR PS15 WITH THE CORRECT TIFF FILES AND STUFF

# %%
# import experiment object and look for number

date = '2021-01-29'
prep = 'PS15'
trials = ['t-001', 't-002', 't-003', 't-005', 't-004', 't-006']

for trial in trials:
    pkl_path = "/home/pshah/mnt/qnap/Analysis/%s/%s/%s_%s.pkl" % (date, prep,
                                                                  date, trial)

    expobj, experiment = aoutils.import_expobj(trial=trial,
                                               date=date,
                                               pkl_path=pkl_path,
                                               verbose=False)
    # expobj.mean_raw_flu_trace(plot=True)
    # aoplot.plotMeanRawFluTrace(expobj=expobj, stim_span_color=None, stim_lines=False, x_axis='frames', figsize=[20, 3],
    #                                        title='Mean raw Flu trace -')
    if len(expobj.tiff_path) == 2:
        pj.plot_single_tiff(expobj.tiff_path[1],
                            frame_num=201,
                            title='%s - frame# 201' % trial)
        print(expobj.tiff_path[1])
    else:
        pj.plot_single_tiff(expobj.tiff_path,
                            frame_num=201,
                            title='%s - frame# 201' % trial)
        print(expobj.tiff_path)
import alloptical_plotting_utils as aoplot
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import utils.funcs_pj as pj
import tifffile as tf

###### IMPORT pkl file containing expobj
trial = 't-016'
date = '2020-12-19'
pkl_path = "/home/pshah/mnt/qnap/Analysis/%s/%s_%s/%s_%s.pkl" % (
    date, date, trial, date, trial)
# pkl_path = "/home/pshah/mnt/qnap/Data/%s/%s_%s/%s_%s.pkl" % (date, date, trial, date, trial)

expobj, experiment = aoutils.import_expobj(trial=trial,
                                           date=date,
                                           pkl_path=pkl_path)

expobj.sz_boundary_csv_done = False  # i know this is a rather very precarious thing here...

if not hasattr(expobj, 's2p_path'):
    expobj.s2p_path = input(
        'input the suite2p path for this trial (to the plane0 folder)!!')
    expobj.save()

if not hasattr(expobj, 'meanRawFluTrace'):
    expobj.mean_raw_flu_trace(plot=True)
    expobj.save()

if not hasattr(expobj, 'stims_in_sz'):
    expobj.seizures_lfp_timing_matarray = expobj.seizures_info_array
Exemple #10
0
    expobj.responses_vs_distance_to_seizure_SLMTargets[
        'distance_to_sz_um'] = round(
            expobj.
            responses_vs_distance_to_seizure_SLMTargets['distance_to_sz'] /
            expobj.pix_sz_x, 2)
    expobj.save()


# run_calculating_min_distance_to_seizure(no_slmtargets_szboundary_stim)
response_type = 'dFF (z scored)'
collect_responses_vs_distance_to_seizure_SLMTargets(
    response_type=response_type)

key = 'f'
exp = 'post'
expobj, experiment = aoutils.import_expobj(aoresults_map_id=f"{exp} {key}.0")

# %%

import concurrent.futures
import time


def somefunc(exp_prep):
    # print(f"\n{'-' * 5} RUNNING PRE4AP TRIALS {'-' * 5}")
    prep = exp_prep[:-6]
    pre4aptrial = exp_prep[-5:]
    expobj, _ = aoutils.import_expobj(prep=prep,
                                      trial=pre4aptrial,
                                      verbose=False)
    return expobj
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

import alloptical_utils_pj as aoutils
import alloptical_plotting_utils as aoplot
from funcsforprajay import funcs as pj

from skimage import draw

# # import results superobject that will collect analyses from various individual experiments
results_object_path = '/home/pshah/mnt/qnap/Analysis/alloptical_results_superobject.pkl'
allopticalResults = aoutils.import_resultsobj(pkl_path=results_object_path)

expobj, experiment = aoutils.import_expobj(prep='RL109', trial='t-013')
"""######### ZONE FOR CALLING THIS SCRIPT DIRECTLY FROM THE SSH SERVER ###########
######### ZONE FOR CALLING THIS SCRIPT DIRECTLY FROM THE SSH SERVER ###########
######### ZONE FOR CALLING THIS SCRIPT DIRECTLY FROM THE SSH SERVER ###########
######### ZONE FOR CALLING THIS SCRIPT DIRECTLY FROM THE SSH SERVER ###########
######### ZONE FOR CALLING THIS SCRIPT DIRECTLY FROM THE SSH SERVER ###########
######### ZONE FOR CALLING THIS SCRIPT DIRECTLY FROM THE SSH SERVER ###########
######### ZONE FOR CALLING THIS SCRIPT DIRECTLY FROM THE SSH SERVER ###########
######### ZONE FOR CALLING THIS SCRIPT DIRECTLY FROM THE SSH SERVER ###########
######### ZONE FOR CALLING THIS SCRIPT DIRECTLY FROM THE SSH SERVER ###########
"""

# sys.exit()
"""# ########### END OF // ZONE FOR CALLING THIS SCRIPT DIRECTLY FROM THE SSH SERVER ###########
########### END OF // ZONE FOR CALLING THIS SCRIPT DIRECTLY FROM THE SSH SERVER ###########
########### END OF // ZONE FOR CALLING THIS SCRIPT DIRECTLY FROM THE SSH SERVER ###########