Пример #1
0
def test_panels():
    pi.message("panel", "this is a test")
    pi.warn("warn", "this is a test")
    pi.ok("ok", "this is a test")
    pi.error("error", "this is a test")

    pi.error("error")
Пример #2
0
"""
    This example shows how to use pyinspect to
    print nice, simple message panels for warning,
    errors etc..
"""

import pyinspect as pi

pi.message("Message", "this is a message panel")
print("\n")  # make some space
pi.warn("Warning: something is weird", "this is a warning panel")
print("\n")  # make some space
pi.ok("All good, relax", "this is an okay panel")
print("\n")  # make some space
pi.error("Alarm, it went wrong!", "this is an error panel, oooops")
print("\n")  # make some space
Пример #3
0
import pyinspect as pi

pi.warn("This is a warning", "Ooops, something might be wrong!")

pi.ok(
    "You got this!",
    "Panels are simple, but nice. Checkout `pyinspect.panels` to see what other kind of panels there are!",
)
Пример #4
0
from caiman.utils.visualization import get_contours
from pathlib import Path
import pickle

from utils import start_server


pi.install_traceback()
print('ready')

fld = Path(r'D:\Dropbox (UCL - SWC)\Project_vgatPAG\analysis\doric\BF136p3_dPAG_ECIC\19MAR11')
cnm_name = fld/'19MAR11_BF136p3_t1_ds126_ffc_crop_cnm.hdf5'

if not cnm_name.exists():
    raise FileExistsError(f'Could not find cnm: {str(cnm_name)}')

c, dview, n_processes = start_server()
cnm = load_CNMF(cnm_name, n_processes=n_processes, dview=dview)

# Spatial components: in a d1 x d2 x n_components matrix
A = np.reshape(cnm.estimates.A.toarray(), list(cnm.estimates.dims)+[-1], order='F') # set of spatial footprints

np.save(fld/'A.npy', A)

conts = get_contours(cnm.estimates.A.toarray(), cnm.estimates.dims)

with open(str(fld/'all_contour_data.pkl'), 'wb') as fp:
    pickle.dump(conts, fp)

pi.ok('Extracted A from cnm', f'Folder \n{fld.parent.name}/{fld.name}')
Пример #5
0
for compn in track(range(n_components)):
    traces[:, compn] = get_component_trace_from_video(compn, masks, n_frames,
                                                      video)

# %%
# Save good traces
save_fld = fld / 'fiji_traces'
save_fld.mkdir(exist_ok=True)

for compn in track(range(n_components)):
    if not isgood[compn]: continue

    # save the mask
    f, ax = plt.subplots(figsize=(10, 10))
    ax.imshow(1 - masks[:, :, compn], cmap='gray_r')
    ax.set(title=f'ROI {compn}', xticks=[], yticks=[])

    save_figure(f, str(save_fld / f'roi_{compn}_mask'), verbose=False)
    del f

    # save the trace
    with open(str(save_fld / f'ROI{compn}.txt'), 'w') as fl:
        for n in traces[:, compn]:
            fl.write(str(n) + '\n')

np.save(str(save_fld / 'masks.npy'), masks)
np.save(str(save_fld / 'traces.npy'), traces)

# %%
pi.ok('Data saved', save_fld.parent.name + '/' + save_fld.name)