• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Pablo1990 / pyVertexModel / 11178329243

04 Oct 2024 10:28AM UTC coverage: 8.915% (-0.02%) from 8.931%
11178329243

push

github

Pablo1990
Improved way of space exploration parameters

0 of 967 branches covered (0.0%)

Branch coverage included in aggregate %.

0 of 12 new or added lines in 1 file covered. (0.0%)

13 existing lines in 2 files now uncovered.

559 of 5303 relevant lines covered (10.54%)

0.11 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/pyVertexModel/analysis/analyse_simulations.py
1
import os
×
2

3
import numpy as np
×
4
import pandas as pd
×
5

6
from src.pyVertexModel.analysis.analyse_simulation import analyse_simulation, analyse_edge_recoil
×
7
from src.pyVertexModel.util.utils import save_variables, load_variables
×
8

9
folder = '/media/pablo/d7c61090-024c-469a-930c-f5ada47fb049/PabloVicenteMunuera/VertexModel/pyVertexModel/Result/'
×
10
all_files_features = []
×
11
lst = os.listdir(folder)
×
12
lst.sort(reverse=True)
×
13
for _, file in enumerate(lst):
×
14
    print(file)
×
15

16
    # if file is a directory
17
    if os.path.isdir(os.path.join(folder, file)):
×
18
        files_within_folder = os.listdir(os.path.join(folder, file))
×
19
        # Analyse the edge recoil
20
        if os.path.exists(os.path.join(folder, file, 'before_ablation.pkl')):
×
21
            # if the analysis file exists, load it
22
            # if os.path.exists(os.path.join(folder, file, 'recoil_info_apical.pkl')):
23
            #     # recoiling_info_df_basal = load_variables(
24
            #     #     os.path.join(folder, file, 'recoil_info_basal.pkl'))['recoiling_info_df_basal']
25
            #     recoiling_info_df_apical = load_variables(
26
            #         os.path.join(folder, file, 'recoil_info_apical.pkl'))['recoiling_info_df_apical']
27
            # else:
28
            file_name = os.path.join(folder, file, 'before_ablation.pkl')
×
29

30
            t_end = 0.5
×
31
            n_ablations = 2
×
32
            recoiling_edge_info_df_apical = analyse_edge_recoil(os.path.join(folder, file, 'before_ablation.pkl'),
×
33
                                                           type_of_ablation='recoil_edge_info_apical',
34
                                                           n_ablations=n_ablations, location_filter=0, t_end=t_end)
35
            if recoiling_edge_info_df_apical is None:
×
36
                continue
×
37

38
            # recoiling_info = analyse_edge_recoil(os.path.join(folder, file, 'data_step_300.pkl'),
39
            #                                      n_ablations=n_ablations, location_filter=2, t_end=t_end)
40
            # recoiling_info_df_basal = pd.DataFrame(recoiling_info)
41
            # recoiling_info_df_basal.to_excel(os.path.join(folder, file, 'recoil_info_basal.xlsx'))
42
            # save_variables({'recoiling_info_df_basal': recoiling_info_df_basal},
43
            #                os.path.join(folder, file, 'recoil_info_basal.pkl'))
44

45
            # Analyse the simulation
46
            features_per_time_df, post_wound_features, important_features, features_per_time_all_cells_df = (
×
47
                analyse_simulation(os.path.join(folder, file)))
48

49
            if important_features is not None and len(important_features) > 5:
×
50
                #important_features['recoiling_speed_apical'] = recoiling_info_df_apical[0]['initial_recoil_in_s']
51
                #important_features['K'] = recoiling_info_df_apical[0]['K']
52

53
                important_features['K_edge'] = np.mean([recoiling_edge_info_df_apical[i]['K'] for i in range(n_ablations) if
×
54
                                                        1 > recoiling_edge_info_df_apical[i]['K'] > 1e-5])
UNCOV
55
                important_features['recoiling_speed_edge_apical'] = np.mean([recoiling_edge_info_df_apical[i]['initial_recoil_in_s'] for i in range(n_ablations) if
×
56
                                                                             1 > recoiling_edge_info_df_apical[i]['initial_recoil_in_s'] > 1e-5])
57

58
                # important_features['recoiling_speed_basal'] = np.mean(recoiling_info_df_basal['initial_recoil_in_s'])
59
                # important_features['recoiling_speed_basal_std'] = np.std(recoiling_info_df_basal['initial_recoil_in_s'])
60

61
                # Sort features_per_time_df by time
62
                features_per_time_df_std = features_per_time_all_cells_df.groupby(by='time').std().reset_index()
×
UNCOV
63
                id_before_ablation = np.where(features_per_time_df_std.time < 30)[0][-1]
×
UNCOV
64
                important_features['std_difference_area_top'] = features_per_time_df_std.loc[id_before_ablation].Area_top - features_per_time_df_std.loc[0].Area_top
×
65

66
                # Count the number of cells that have an area_top lower than the average area_top
67
                features_per_time_df_mean = features_per_time_all_cells_df.groupby(by='time').mean().reset_index()
×
68
                count_of_smalls_cells_per_time_0 = features_per_time_all_cells_df[features_per_time_all_cells_df.Area_top < features_per_time_df_mean.loc[0].Area_top].groupby(by='time').count().reset_index()
×
69
                count_of_smalls_cells_per_time_ablation = features_per_time_all_cells_df[features_per_time_all_cells_df.Area_top < features_per_time_df_mean.loc[id_before_ablation].Area_top].groupby(by='time').count().reset_index()
×
70
                try:
×
71
                    important_features['cells_area_top_lower_than_average_diff'] = count_of_smalls_cells_per_time_ablation.loc[id_before_ablation].ID - count_of_smalls_cells_per_time_0.loc[0].ID
×
72
                except KeyError as e:
×
73
                    #print("Error cells_area_top_lower_than_average_diff: ", e)
74
                    important_features['cells_area_top_lower_than_average_diff'] = np.nan
×
75

UNCOV
76
                important_features['folder'] = file
×
77

78
                # Extract the variables from folder name
UNCOV
79
                file_splitted = file.split('_')
×
80
                variables_to_show = {'Cells', 'visc', 'lVol', 'refV0', 'kSubs', 'lt', 'ltExt', 'refA0', 'eTriAreaBarrier',
×
81
                                     'eARBarrier', 'RemStiff', 'lS1', 'lS2', 'lS3', 'pString'}
82
                for i in range(3, len(file_splitted), 1):
×
UNCOV
83
                    if file_splitted[i] in variables_to_show:
×
UNCOV
84
                        important_features[file_splitted[i]] = file_splitted[i + 1]
×
85

86
                # Transform the dictionary into a dataframe
UNCOV
87
                important_features = pd.DataFrame([important_features])
×
UNCOV
88
                all_files_features.append(important_features)
×
89

90
# Concatenate the elements of the list all_files_features
UNCOV
91
all_files_features = pd.concat(all_files_features, axis=0)
×
92

93
# Export to xls file
UNCOV
94
df = pd.DataFrame(all_files_features)
×
UNCOV
95
df.to_excel(os.path.join(folder, 'all_files_features.xlsx'))
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc