<jupyter_start><jupyter_text>From raw *.ome.tif file to kinetic properties for immobile particlesThis notebook will run ... * picasso_addon.localize.main()* picasso_addon.autopick.main()* spt.immobile_props.main()... in a single run to get from the raw data to the fully evaluated data in a single stroke. We therefore: 1. Define the full paths to the *ome.tif files2. Set the execution parameters3. Connect or start a local dask parallel computing cluster4. Run all sub-module main() functions for all defined datasetsAs a result files with extension *_locs.hdf5, *_render.hdf5, *_autopick.yaml, *_tprops.hdf5 will be created in the same folder as the *.ome.tif file.<jupyter_code>import os
import traceback
import importlib
from dask.distributed import Client
import multiprocessing as mp

import picasso.io as io
import picasso_addon.localize as localize
import picasso_addon.autopick as autopick
import spt.immobile_props as improps

importlib.reload(localize)
importlib.reload(autopick)
importlib.reload(improps)<jupyter_output><empty_output><jupyter_text>1. Define the full paths to the *ome.tif files<jupyter_code>dir_names=[]
dir_names.extend([r'C:\Data\p06.SP-tracking\20-03-11_pseries_fix_B21_rep\id140_B_exp200_p114uW_T21_1\test'])

file_names=[]
file_names.extend(['id140_B_exp200_p114uW_T21_1_MMStack_Pos0.ome.tif'])<jupyter_output><empty_output><jupyter_text>2. Set the execution parameters<jupyter_code>### Valid for all evaluations
params_all={'undrift':False,
            'min_n_locs':5,
            'filter':'fix',
            }

### Exceptions
params_special={}<jupyter_output><empty_output><jupyter_text>All possible parameters for ...* picasso_addon.localize.main()* picasso_addon.autopick.main()* spt.immobile_props.main() ... can be given. Please run `help(localize.main)` or `help(autopick.main)` or `help(improps.main)` or readthedocs. If not stated otherwise standard values are used (indicated in brackets).<jupyter_code>help(localize.main)<jupyter_output>Help on function main in module picasso_addon.localize:

main(file, info, path, **params)
    Localize movie (least squares, GPU fitting if available) and undrift resulting localizations using rcc.
     
    Args:
        file(picasso.io):          Either raw movie loaded with picasso.io.load_movie() or_locs.hdf5 loaded with picasso.io.load_locs()
        info(list(dicts)):         Info to raw movie/_locs.hdf5 loaded with picasso.io.load_movie() or picasso.io.load_locs()
    
    Keyword Arguments:
        localize(bool=True)        Localize raw movie (see picasso.localize)
        baseline(int=70):          Camera spec. baseline (see picasso.localize).
        gain(float=1):             Camera spec. EM gain (see picasso.localize)
        sensitivity(float=0.56):   Camera spec. sensitivity (see picasso.localize)
        qe(float=0.82):            Camera spec. sensitivity (see picasso.localize)
        box(int=5):                Box length (uneven!) of fitted spots (see picasso.localize[...]<jupyter_text>3. Connect or start a local dask parallel computing clusterThis is only necessary if you want to use parallel computing for the spt.immobile.props.main() execution (standard). If not set `params_all={'parallel':False}`<jupyter_code>try:
    client = Client('localhost:8787')
    print('Connecting to existing cluster...')
except OSError:
    improps.cluster_setup_howto()<jupyter_output>Connecting to existing cluster...<jupyter_text>If we execute the prompt (see below) a local cluster is started, and we only have to execute the cell above  to reconnect to it the next time. If you try to create a new cluster under the same address this will throw an error!<jupyter_code>Client(n_workers=max(1,int(0.8 * mp.cpu_count())),
       processes=True,
       threads_per_worker=1,
       scheduler_port=8787,
       dashboard_address=":1234")<jupyter_output><empty_output><jupyter_text>4. Run all sub-module main() functions for all defined datasets<jupyter_code>failed_path=[]
for i in range(0,len(file_names)):
    ### Create path
    path=os.path.join(dir_names[i],file_names[i])
    
    ### Set paramters for each run
    params=params_all.copy()
    for key, value in params_special.items():
        params[key]=value[i]
        
    ### Run main function
    try:
        ### Load movie
        movie,info=io.load_movie(path)
        
        ### Localize and undrift
        out=localize.main(movie,info,path,**params)
        info=info+[out[0][0]]+[out[0][1]] # Update info to used params
        path=out[-1] # Update path
        
        ### Autopick
        print()
        locs=out[1]
        out=autopick.main(locs,info,path,**params)
        info=info+[out[0]] # Update info to used params
        path=out[-1] # Update path
        
        ### Immobile kinetics analysis
        print()
        locs=out[1]
        out=improps.main(locs,info,path,**params)
        
    except Exception:
        traceback.print_exc()
        failed_path.extend([path])

print()    
print('Failed attempts: %i'%(len(failed_path)))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10772880015813402, 'fraction_numerical': 0.016801739474204387, 'mean_word_length': 3.796208530805687, 'pattern_counts': {'":': 1, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '5672', 'license': 'MIT', 'n_tokens_mistral': 1666, 'n_tokens_neox': 1602, 'n_words': 425, 'path': 'scripts/workflow/notebooks/00_master_immob.ipynb', 'repo_name': 'schwille-paint/SPT', 'size': '5059'}