<commit_before># -*- coding: utf-8 -*-
"""
Created on Thu Jun 25 12:44:07 2015

@author: ajaver
"""

import json
import os
from tierpsy import AUX_FILES_DIR
#get default parameters files
from tierpsy import DFLT_PARAMS_PATH, DFLT_PARAMS_FILES


#deprecated variables that will be ignored
deprecated_fields = ['has_timestamp', 'min_displacement']

#the dict key are the old names and the value the new name
deprecated_alias = {
    'fps': 'expected_fps',
    'threshold_factor': 'worm_bw_thresh_factor',
    'is_invert_thresh' : 'is_light_background',
    'is_fluorescence' : 'is_light_background',
    'min_length' : 'min_box_width',
    'max_area' : 'mask_max_area',
    'save_int_maps': 'int_save_maps'}

dflt_param_list = [
    ('mask_min_area', 50, 'minimum allowed area in pixels allowed for in the compression mask.'),
    ('mask_max_area', int(1e8), 'maximum allowed area in pixels allowed for in the compression mask..'),
    ('min_box_width', 5, 'minimum allowed width of bounding box in pxels.'),
    ('thresh_C', 15, 'constant offset used by the adaptative thresholding to calculate the mask.'),
    ('thresh_block_size', 61, 'block size used by the adaptative thresholding.'),
    ('dilation_size', 9, 'size of the structural element used in morphological operations to calculate the worm mask.'),
    ('expected_fps', 25, 'expected frame rate.'),
    ('compression_buff', -1, 'number of images "min-averaged" to calculate the image mask. If it is -1 the program will read the expected_fps from the file.'),
    ('keep_border_data', False, 'set it to false if you want to remove any connected component that touches the border.'),
    ('is_light_background', True, 'set to true to indentify dark worms over a light background.'),
    ('traj_min_area', 25, 'minimum allowed area in pixels allowed for the trajectories and the videos.'),
    ('traj_max_allowed_dist', 25, 'Maximum displacement expected between frames to be consider same track.'),
    ('traj_area_ratio_lim', [0.5, 2], 'Limits of the consecutive blob areas to be consider the same object.'),
    ('worm_bw_thresh_factor', 1.05, 'This factor multiplies the threshold used to binarize the individual worms image.'),
    ('resampling_N', 49, 'number of segments used to renormalize the worm skeleton and contours.'),
    ('max_gap_allowed_block', -1, 'maximum time gap allowed between valid skeletons to be considered as belonging in the same group. Head/Tail correction by movement.'),
    ('strel_size', 5, 'Structural element size. Used to calculate skeletons and trajectories.'),
    ('fps_filter', 0, 'PROBALY USELESS (Used in joinTrajectories). frame per second used to calculate filters for trajectories. Set to zero to eliminate filtering.'),
    
    ('ht_orient_segment', -1, 'Segment size to calculate the head_tail.'),

    ('filt_bad_seg_thresh', 0.8, 'minimum fraction of succesfully skeletonized frames in a worm trajectory to be considered valid'),
    ('filt_min_displacement', 10, 'minimum total displacement of a trajectory to be used to calculate the threshold to dectect bad skeletons.'),
    ('filt_critical_alpha', 0.01, 'critical chi2 alpha used in the mahalanobis distance to considered a worm a global outlier.'),
    ('filt_max_width_ratio', 2.25, 'Maximum width radio between midbody and head or tail. Does the worm more than double its width from the head/tail? Useful for coils.'),
    ('filt_max_area_ratio', 6, 'maximum area ratio between head+tail and the rest of the body to be a valid worm.  Are the head and tail too small (or the body too large)?'),
    
    ('int_save_maps', False, 'save the intensity maps and not only the profile along the worm major axis.'),
    ('int_avg_width_frac', 0.3, 'width fraction from the center used to calculate the worm axis intensity profile.'),
    ('int_width_resampling', 15, 'width in pixels of the intensity maps'),
    ('int_length_resampling', 131, 'length in pixels of the intensity maps'),
    ('int_max_gap_allowed_block', -1, 'maximum time gap allowed between valid intensity maps to be considered as belonging in the same group. Head/Tail correction by intensity.'),
    ('head_tail_int_method', 'MEDIAN_INT', 'method to correct head/tail based on intensity profile')
    ('split_traj_time', 300, 'time in SECONDS that a trajectory will be subdivided to calculate the splitted features.'),
    ('roi_size', -1, ''),
    ('filter_model_name', '', ''),
    ('n_cores_used', 1, 'Number of core used. Currently it is only suported by TRAJ_CREATE and it is only recommended at high particle densities.'),
    
    ('mask_bgnd_buff_size', -1, 'Number of images to keep to calculate the background (mask compression).'),
    ('mask_bgnd_frame_gap', -1, 'Frame gap between images used to calculate the background (mask compression).'),

    ('traj_bgnd_buff_size', -1, 'Number of images to keep to calculate the background (trajectories/skeletons).'),
    ('traj_bgnd_frame_gap', -1, 'Frame gap between images used to calculate the background (trajectories/skeletons).'),

<commit_msg>typo bug<commit_after># -*- coding: utf-8 -*-
"""
Created on Thu Jun 25 12:44:07 2015

@author: ajaver
"""

import json
import os
from tierpsy import AUX_FILES_DIR
#get default parameters files
from tierpsy import DFLT_PARAMS_PATH, DFLT_PARAMS_FILES


#deprecated variables that will be ignored
deprecated_fields = ['has_timestamp', 'min_displacement']

#the dict key are the old names and the value the new name
deprecated_alias = {
    'fps': 'expected_fps',
    'threshold_factor': 'worm_bw_thresh_factor',
    'is_invert_thresh' : 'is_light_background',
    'is_fluorescence' : 'is_light_background',
    'min_length' : 'min_box_width',
    'max_area' : 'mask_max_area',
    'save_int_maps': 'int_save_maps'}

dflt_param_list = [
    ('mask_min_area', 50, 'minimum allowed area in pixels allowed for in the compression mask.'),
    ('mask_max_area', int(1e8), 'maximum allowed area in pixels allowed for in the compression mask..'),
    ('min_box_width', 5, 'minimum allowed width of bounding box in pxels.'),
    ('thresh_C', 15, 'constant offset used by the adaptative thresholding to calculate the mask.'),
    ('thresh_block_size', 61, 'block size used by the adaptative thresholding.'),
    ('dilation_size', 9, 'size of the structural element used in morphological operations to calculate the worm mask.'),
    ('expected_fps', 25, 'expected frame rate.'),
    ('compression_buff', -1, 'number of images "min-averaged" to calculate the image mask. If it is -1 the program will read the expected_fps from the file.'),
    ('keep_border_data', False, 'set it to false if you want to remove any connected component that touches the border.'),
    ('is_light_background', True, 'set to true to indentify dark worms over a light background.'),
    ('traj_min_area', 25, 'minimum allowed area in pixels allowed for the trajectories and the videos.'),
    ('traj_max_allowed_dist', 25, 'Maximum displacement expected between frames to be consider same track.'),
    ('traj_area_ratio_lim', [0.5, 2], 'Limits of the consecutive blob areas to be consider the same object.'),
    ('worm_bw_thresh_factor', 1.05, 'This factor multiplies the threshold used to binarize the individual worms image.'),
    ('resampling_N', 49, 'number of segments used to renormalize the worm skeleton and contours.'),
    ('max_gap_allowed_block', -1, 'maximum time gap allowed between valid skeletons to be considered as belonging in the same group. Head/Tail correction by movement.'),
    ('strel_size', 5, 'Structural element size. Used to calculate skeletons and trajectories.'),
    ('fps_filter', 0, 'PROBALY USELESS (Used in joinTrajectories). frame per second used to calculate filters for trajectories. Set to zero to eliminate filtering.'),
    
    ('ht_orient_segment', -1, 'Segment size to calculate the head_tail.'),

    ('filt_bad_seg_thresh', 0.8, 'minimum fraction of succesfully skeletonized frames in a worm trajectory to be considered valid'),
    ('filt_min_displacement', 10, 'minimum total displacement of a trajectory to be used to calculate the threshold to dectect bad skeletons.'),
    ('filt_critical_alpha', 0.01, 'critical chi2 alpha used in the mahalanobis distance to considered a worm a global outlier.'),
    ('filt_max_width_ratio', 2.25, 'Maximum width radio between midbody and head or tail. Does the worm more than double its width from the head/tail? Useful for coils.'),
    ('filt_max_area_ratio', 6, 'maximum area ratio between head+tail and the rest of the body to be a valid worm.  Are the head and tail too small (or the body too large)?'),
    
    ('int_save_maps', False, 'save the intensity maps and not only the profile along the worm major axis.'),
    ('int_avg_width_frac', 0.3, 'width fraction from the center used to calculate the worm axis intensity profile.'),
    ('int_width_resampling', 15, 'width in pixels of the intensity maps'),
    ('int_length_resampling', 131, 'length in pixels of the intensity maps'),
    ('int_max_gap_allowed_block', -1, 'maximum time gap allowed between valid intensity maps to be considered as belonging in the same group. Head/Tail correction by intensity.'),
    ('head_tail_int_method', 'MEDIAN_INT', 'method to correct head/tail based on intensity profile'),
    ('split_traj_time', 300, 'time in SECONDS that a trajectory will be subdivided to calculate the splitted features.'),
    ('roi_size', -1, ''),
    ('filter_model_name', '', ''),
    ('n_cores_used', 1, 'Number of core used. Currently it is only suported by TRAJ_CREATE and it is only recommended at high particle densities.'),
    
    ('mask_bgnd_buff_size', -1, 'Number of images to keep to calculate the background (mask compression).'),
    ('mask_bgnd_frame_gap', -1, 'Frame gap between images used to calculate the background (mask compression).'),

    ('traj_bgnd_buff_size', -1, 'Number of images to keep to calculate the background (trajectories/skeletons).'),
    ('traj_bgnd_frame_gap', -1, 'Frame gap between images used to calculate the background (trajectories/skeletons).'),


{'fraction_non_alphanumeric': 0.10160905840286055, 'fraction_numerical': 0.014302741358760428, 'mean_word_length': 4.575304540420819, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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}}
{'dir': 'git-commits-cleaned', 'id': '6252103', 'n_tokens_mistral': 3073, 'n_tokens_neox': 2867, 'n_words': 1225}