def query(self, term, symptoms_side, dominant_hemisphere): path = semiology_dict_path if term in all_semiology_terms else None query_semiology_result, num_query_lat, num_query_loc = QUERY_SEMIOLOGY( mega_analysis_df, semiology_term=term, semiology_dict_path=path, ) if query_semiology_result is None: return None all_combined_gifs, num_QL_lat, num_QL_CL, num_QL_IL, num_QL_BL, num_QL_DomH, num_QL_NonDomH = QUERY_LATERALISATION( query_semiology_result, mega_analysis_df, one_map, gif_lat_file, side_of_symptoms_signs=symptoms_side.value, pts_dominant_hemisphere_R_or_L=dominant_hemisphere.value, ) if all_combined_gifs is None: pivot_result = melt_then_pivot_query( mega_analysis_df, query_semiology_result, term, ) all_combined_gifs = pivot_result_to_one_map(pivot_result, one_map) return all_combined_gifs
def query(self, term): path = semiology_dict_path if term in all_semiology_terms else None inspect_result, num_query_lat, num_query_loc = QUERY_SEMIOLOGY( mega_analysis_df, semiology_term=term, semiology_dict_path=path, ) return path, inspect_result
def test_parenthesis_and_caps_QUERY_SEMIOLOGY_with_dictionary(self): query, num_query_lat, num_query_loc = QUERY_SEMIOLOGY( self.df, # see dummy_SemioDict: equivalent to "Aphasia" semiology_term='dummy_test_link_aphasia', ignore_case=False, # in QUERY_SEMIO re.IGNORECASE is used for dictionary anyway semiology_dict_path=dummy_semiology_dict_path, col1='Reported Semiology', col2='Semiology Category', ) assert (query['Localising'].sum() == 14) assert (query['Lateralising'].sum() == 6)
def test_parenthesis_and_caps_QUERY_SEMIOLOGY_regex_pickup(self): """ default QUERY_SEMIOLOGY doesn't exclude paed cases """ query, num_query_lat, num_query_loc = QUERY_SEMIOLOGY( self.df, semiology_term=['aphasia'], ignore_case=True, semiology_dict_path=None, col1='Reported Semiology', col2='Semiology Category', ) assert (query['Localising'].sum() == 14) assert (query['Lateralising'].sum() == 6)
def test_caps_QUERY_SEMIOLOGY_regex_pickup(self): """ when ignore case is false, it won't pick up case mismatches. so sum is slightly less. """ query, num_query_lat, num_query_loc = QUERY_SEMIOLOGY( self.df, semiology_term=['aphasia'], ignore_case=False, semiology_dict_path=None, col1='Reported Semiology', col2='Semiology Category', ) assert (query['Localising'].sum() == 13) assert (query['Lateralising'].sum() == 6)
def test_only_postictal_cases(self): """ Include only the single postictal aphasia. Note Dominant in dummy data. cf test_postictal_exclusions """ # Low level test df_postictal = only_postictal_cases(self.df) query, num_query_lat, num_query_loc = QUERY_SEMIOLOGY( df_postictal, semiology_term=['aphasia'], ignore_case=True, semiology_dict_path=None, col1='Reported Semiology', col2='Semiology Category', ) assert (query['Localising'].sum() == 1) assert (query['Lateralising'].sum() == 1) # High level test patient = Semiology('aphasia', Laterality.NEUTRAL, dominant_hemisphere=Laterality.LEFT) patient.data_frame = self.df patient.include_postictals = True patient.include_only_postictals = True patient.granular = True lat_allgifs = patient.query_lateralisation(one_map_dummy) lat_allgifs = lat_allgifs[['Gif Parcellations', 'pt #s']].astype({ 'Gif Parcellations': 'int32', 'pt #s': 'int32' }) lat_allgifs.set_index('Gif Parcellations', inplace=True) # note that dominant_hemisphere == Laterality.LEFT as set above. Just to clarify results change if dominace changes. Also 1's become 2's if not granular. assert (lat_allgifs.loc[164, 'pt #s'] == 1) assert (lat_allgifs.loc[166, 'pt #s'] == 1) assert (lat_allgifs.loc[163, 'pt #s'] == 0) assert (lat_allgifs.loc[165, 'pt #s'] == 0) lat_allgifs = lat_allgifs.loc[lat_allgifs['pt #s'] != 0, :] SVT_output, _ = patient.get_num_datapoints_dict(method='minmax') assert SVT_output == dict((lat_allgifs)['pt #s'])
def test_postictal_exclusion(self): """ Exclude the single postictal aphasia. After update in June, default is to exclude postictals. So the result of this should be the same as query_semiology() """ df_excl = exclusions(self.df) query, num_query_lat, num_query_loc = QUERY_SEMIOLOGY( df_excl, semiology_term=['aphasia'], ignore_case=True, semiology_dict_path=None, col1='Reported Semiology', col2='Semiology Category', ) assert (query['Localising'].sum() == 13) assert (query['Lateralising'].sum() == 5) print('\n2.2 postictal\n')