thenineteen / Semiology-Visualisation-Tool

Data driven 3D brain visualisation of semiology. Semiology to anatomy translator based on over 4600 patients from 309 peer-reviewed articles.
MIT License
9 stars 6 forks source link

Add inclusion options in Slicer GUI #21

Closed fepegar closed 4 years ago

fepegar commented 4 years ago

Transferred from https://github.com/fepegar/EpilepsySemiology/issues/2, @thenineteen said:

need four cross-boxes in slicer under one heading Ground Truth and Prior Inclusions to filter results:

By default all the check boxes should be ticked. If any of the check boxes ARE UNTICKED then these scripts are run from Semiology-Visualisation-Tool::

e.g. if the 2. concordance box is unticked

from SVT import resources

path_to_file = resources/DataFrames_Exclusions_df_postictalPEThyper_concordance_ET.pickle
with open(path_to_file, 'rb') as f:
    data = pickle.load(f)
 _, _, df_exclusions_concordance, _ = data

alternative solution for above: after running the MEGA_ANALYSIS (or using the first pickled df):

from SVT.mega_analysis.crosstab.mega_analysis import exclusions

df_exclusions_concordance = exclusions(df, 
                POST_ictals=False,
                PET_hypermetabolism=False,
                SPECT_PET=False,
                CONCORDANCE=True)

The other most useful cross-out-box would be

When unticked, it should run this from exclusions.py:

exclude_ET(df)
fepegar commented 4 years ago

Transferred from https://github.com/fepegar/EpilepsySemiology/issues/2, @thenineteen said:

see try/except clauses under scripts in

slicer_run_query_semiology_lateralisation.py

this should replace mega_analysis_test.py

I didn't know how your tickboxes work so you will need to update the if statements, specifically how the tick boxes being ticked (True) or unticked (False) logic works, once you've done this pleas remove the try/except clauses so it does throw an error if it can't load module:

try:
    if slicer_tickbox_concordance == False:
        df_exclusions_concordance = exclusions(df, 
                POST_ictals=False,
                PET_hypermetabolism=False,
                SPECT_PET=False,
                CONCORDANCE=True)
        df = df_exclusions_concordance
except: pass

try:
    if slicer_tickbox_ET == False:

        df = exclude_ET(df)
except: pass

try:
    if slicer_tickbox_sEEG_ES == False:
        df = exclude_sEEG_ES(df)
except: pass
fepegar commented 4 years ago

If mega_analysis can't handle exclusions, there's no point in including these options in the GUI yet.

fepegar commented 4 years ago

Fixed in https://github.com/thenineteen/Semiology-Visualisation-Tool/commit/38eef7a0c25268dd4b619503d03d6a708b1c25ad.

thenineteen commented 4 years ago

need also checkbox which is ticked by default, but we could untick, appended to the above tickboxes:

if unticked, it should call a new function (to be appended to the exclusions.py module) which filters the present DataFrame as such:

def exclude_paediatric(df):
    paediatric_col = 'padeiatric? <7 years (0-6 yrs) y/n'
    df_exclude_paeds = df.loc[df[paediatric_col ]!='y']

    return df_exclude_paeds 
fepegar commented 4 years ago

Is this for each semiology or for all of them?

thenineteen commented 4 years ago

so all of the above options are global options, whether looking at one semiology alone or combinations

fepegar commented 4 years ago

Which one did we say should be specific for each semiology the other day?

thenineteen commented 4 years ago

that was lateralisation:

it probably makes more sense to have a global dominant hemisphere defined, which is specific and constant for each patient (i.e. each search for however number of different semiologies). (Patient Class so to speak)

The symptoms_or_signs_lateralisations should be a member of the Semiology Class, which can be altered for each semiology: e.g. right asymmetric tonic, L automatisms should be ccombined (can't do this currently.)

at the same time, the post-ictal semiolgies should also be modified so that they can switched on /off for each semiology, just like symptoms_or_signs_lateralisations

thenineteen commented 4 years ago

this would be highly useful to have...

neurokleos commented 4 years ago

I would edit the filters as follows, to better explain what actually we are filtering out:

or, if this is too wordy, we can divide it in this way:

  1. Post-Surgical Seizure-Freedom
  2. Multimodal Concordance Imaging-Neurophysiology
  3. Invasive EEG Monitoring
  1. Papers sampling for Epilepsy Topology (e.g. TLE)
  2. Papers sampling for Seizure Semiology (e.g. gelastic)
  3. Papers sampling for Electrical Brain Stimulation
neurokleos commented 4 years ago

Hemispheric Dominance

it is fine to have as default choice Left Hemisphere (and in case the patient is instead known to be R dominant or ND, to give such options), and I would expect that by selecting "Aphasia" I will see data on the L hemisphere, and if I select "Ictal speech" on the R hemisphere . The latter semiology is not in the list yet, but when I select Aphasia I can only see bilateral data. I remember this was just a code-related issue, right?

thenineteen commented 4 years ago

SVT improvements

thenineteen commented 4 years ago

The postictals: I'm not sure how you would do this, given when the data loads slicer runs an exclusions. I can think of the following for postictals:

  1. if we click on nose wiping, then left laterality, then postictal checkbox, slicer has to run MEGA_ANALYSIS again to load the data, this time only including postictals. (not the same as not excluding them).
  2. remove the exclusions modules from MEGA_ANALYSIS so that they are not run when slicer loads the data. Then for each semiology, when we click on the semiology checkbox and the laterality, the data is then fiktered to exclude postictals. This way, I can create separate semiologies for postictals, and you tell them not to run the exclusion for these three semiologies (nose wiping, drinking, postictal limb paresis)

option 1 is probably easiest, concur?

fepegar commented 4 years ago

There are a lot of comments here. Let's see.

  1. You guys are proposing different GUI designs. Gloria's: https://github.com/thenineteen/Semiology-Visualisation-Tool/issues/21#issuecomment-622546762. I like splitting them into two groups. The other is Ali's image: https://github.com/thenineteen/Semiology-Visualisation-Tool/issues/21#issuecomment-624700250. You need to find an agreement so that I know what to implement.
  2. Before writing a GUI, this needs to be solved at a lower level, i.e. in mega_anaysis.

At the moment, Slicer calls only the function combine_semiologies(semiologies), where semiologies is a list of instances of Semiology. Both the function and the class are implemented in the mega_analysis.semiology module.

Each instance of Semiology is instantiated as follows: https://github.com/thenineteen/Semiology-Visualisation-Tool/blob/3da076fcd797419aa719c99849ff8364296ff855/slicer/SemiologyVisualization.py#L240-L244

But the constructor (__init__ method) of the Semiology class takes more arguments, currently unused by Slicer: https://github.com/thenineteen/Semiology-Visualisation-Tool/blob/3da076fcd797419aa719c99849ff8364296ff855/mega_analysis/semiology.py#L78-L104

As you can see, the exclusion options implemented so far, all disabled by default, are

seizure_freedom
concordance
seeg
cortical_stimulation
et_topology_ez

If I compare that to Gloria's suggestion, the "Papers sampling for Seizure Semiology (e.g. gelastic)" option seems to be missing.

If I compare that to Ali's suggestion, the "Spontaneous semiology" and "Pediatric", options seem to be missing. And Ali didn't include the SEEG option.

The Semiology class filters the table (data frame) computed by MEGA_ANALYSIS (with default parameters) like this: https://github.com/thenineteen/Semiology-Visualisation-Tool/blob/3da076fcd797419aa719c99849ff8364296ff855/mega_analysis/semiology.py#L107-L125

All those exclusion functions were implemented by @thenineteen and can be found in mega_analysis.crosstab.mega_analysis.exclusions.

It seems like what we need is a couple more exclusion functions: post-ictal, paediatric and spontaneous semiology. Is that correct?

thenineteen commented 4 years ago

Yes, that is correct

Gloria's version is the correct one, two categories, ground truth and patient selection priors. Can add the paediatric cases to patient selection priors.

I'll write the remaining 2 remaining functions: paeds and spontaneous; and extract postictal exclusion from within the mega_analysis function

fepegar commented 4 years ago

Ok, cool. Please open a PR, so that we can make sure all tests are passing before merging. Once everything is ready, I'll add the options to the GUI.

neurokleos commented 4 years ago

Glad we agreed on the GT and publications filters!

As for the post-ictal semiology - just a proposal - I would probably just double within the semiology list those semiologies that can have either early ictal vs post-ictal presentation, and in consequence different value: early onset having both lateralising and localising power, while post-ictal only lateralising. So by listing e.g. both ictal and post-ictal aphasia, or ictal and post-ictal paresis, we give on one side more fine options to the user, that can better interact with the tool, and on the other side we select the appropriate lat/loc data points from the database for each semiology. At the moment, we are experimentally collecting localising data also for post-ictal semiology, and started recently to take note of paediatric data when < 7yo, but this kind of data collection is not homogeneous and not fully rationalised in all its pros and cons, so I would not tailor the code to circumvent this experimental/dirty data collection - I would put instead more efforts in refining the database, to make it more tidy and homogeneous, once finished the screening. Once digested, I guess we will find other factors that would be worth using as additional filters, in addition to age<7y, so we can create a third category of additional filters.

fepegar commented 4 years ago

Inclusion filters added in c7a0abd86b1be93266669395da90bdda952a00ac

I'm going to add tooltips with the definitions in the README.

Screenshot 2020-05-09 06 49 09

Will add the rest once @thenineteen have implemented them and tests are passing.

fepegar commented 4 years ago

This is what tooltips look like:

Screenshot 2020-05-09 07 19 16
neurokleos commented 4 years ago

That's great!! Well done! Could you just please change from StereoEEG to "Invasive EEG monitoring"?

neurokleos commented 4 years ago

If we want to be super-precise, it would be even better to swap the invasive EEG monitoring from third line to the second, and put concordance as third option.

fepegar commented 4 years ago

Done. Why does the order matter?

neurokleos commented 4 years ago

The order of the options does not change the substance, I know, but visually it can be a clue to weight the strength of the the ground truths, as post-op sz freedom is the strongest, the invasive EEG monitoring is the 2nd strongest and the multimodal concordance is the 3rd, and kind of weak in comparison to the first 2.

fepegar commented 4 years ago

Ok, thanks!

thenineteen commented 4 years ago

@neurokleos

That's great!! Well done! Could you just please change from StereoEEG to "Invasive EEG monitoring"?

Gloria can you clarify why? We included sEEG and CES for invasive moniting, not subdural grids, so why invasive? invasive would suggest we included subdural grids? What am I missing?

thenineteen commented 4 years ago

@fepegar

currently we have exclusion options. But looking at the GUI, it feels that having inclusion options might be more intuitive. Are you happy for me to still finish the peadiatric, spontaenous and post-ictals as exclusions? i.e. when the checkbox is unticked, it runs these functions?

fepegar commented 4 years ago

currently we have exclusion options.

Do you mean that's what's coded in mega_analysis? I don't think it's worth it to change everything. The Semiology class handles it well with the if not include statements I pasted above.

If you add more exclusion options, I'll add the corresponding inclusions to Slicer.

thenineteen commented 4 years ago

ok I've done this

see pull request