Giter VIP home page Giter VIP logo

enigma_meg's People

Contributors

amnamyst avatar jstout211 avatar nugenta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

lychfindel

enigma_meg's Issues

Create QA images using MNE Report

In the final process_meg function:
Write raw-cov.fif
Write eroom-cov.fif
Write -trans.fif
Write downsampled...fif

from mne import Report

#Run the following to collect and write out the QA files
report = Report(image_format='png', subjects_dir=subjects_dir,
subject='APBWVFAR_fs_ortho', info_fname='APBWVFAR_300fs_meg.fif',
raw_psd=False) # use False for speed here

meg_path = '/home/stoutjd/data/DEMO_ENIGMA/outputs/APBWVFAR_fs_ortho'
report.parse_folder(meg_path, on_error='ignore', mri_decim=10)
report.save('outfile.html')

Print Null image if overflow past the image_list length

def create_window_layout(image_list=None, sub_obj_list=None, qa_type=None, grid_size=GRID_SIZE,
                    frame_start_idx=0, resize_xy=(600,600)):
    layout = [[sg.Text(f'QA: {qa_type}')]]
    frame_end_idx=frame_start_idx+grid_size[0]*grid_size[1]
    current_idx = copy.deepcopy(frame_start_idx)
    for i in range(grid_size[0]):
        row = []
        for j in range(grid_size[1]):
            if current_idx > len(image_list):
                print('None Available')    **#!!! FIX - show a null image**

ICA cleaned png

Something in here is causing errors that prevent the code from completing

        QAdir = op.join(self.bids_root,'derivatives/ENIGMA_MEG_QA')
        QAsubjdir = QAdir + '/sub-' + self.subject + '/ses-' + self.session
        figname_icaoverlay = QAsubjdir + '/sub-' + self.subject + '_ses-' + self.session + '_run-' + self.run + '_cleaned.png'
        ica=mne.preprocessing.read_ica(op.join(self.fnames.ica))
        ica.exclude = self.ica_comps_toremove #meg_rest_raw.icacomps
        self.load_data()
        fig=ica.plot_overlay(self.raw_rest, exclude=self.ica_comps_toremove)
        fig.savefig(figname_icaoverlay)

Tensorflow add ons issue

Remove model dependency on tensorflow addons (currently required because of the f1_score). Tensorflow addons is currently required to load the model. The source code support will be deprecated 2024.

Solution - compile model without f1_score metric or use f1_score metric from another source -- see below announcement. Sci-kit learn also has an f1 score metric.

planned end of life in May 2024. Please modify downstream libraries to take dependencies from other repositories in our TensorFlow community (e.g. Keras, Keras-CV, and Keras-NLP)

For more information see: https://github.com/tensorflow/addons/issues/2807

Precompile base64 images to object tag

There is a lag between "page" turns / next because the images have to be resized and converted to base64.

This should be done before the GUI component is run to prevent lags.

Rank Calculation for beamformer

    proc.do_proc_allsteps()
  File "/vf/users/MEGmodules/modules/enigma_meg0.2_extras/enigma_MEG/enigmeg/process_meg.py", line 504, in do_proc_allsteps
    self.do_beamformer()
  File "/vf/users/MEGmodules/modules/enigma_meg0.2_extras/enigma_MEG/enigmeg/process_meg.py", line 374, in do_beamformer
    if epo_rank < noise_rank:
TypeError: '<' not supported between instances of 'dict' and 'dict'

Solution - set the rank according to sensor type

            if 'mag' in epo_rank:
                if epo_rank['mag'] < noise_rank['mag']:
                    noise_rank['mag']=epo_rank['mag']
            if 'grad' in epo_rank:
                if epo_rank['grad'] < noise_rank['grad']:
                    noise_rank['grad']=epo_rank['grad']

Datasets without emptyroom not running properly

ValueError                                Traceback (most recent call last)
Cell In [7], line 1
----> 1 proc.load_data()

File /vf/users/MEGmodules/modules/enigma_meg0.2_extras/enigma_MEG/enigmeg/process_meg.py:188, in process.load_data(self)
    186     self.raw_rest.pick_types(meg=True, eeg=False)
    187 if not hasattr(self, 'raw_eroom'):
--> 188     self.raw_eroom = load_data(self.meg_er_raw.fpath) 
    189     self.raw_eroom.pick_types(meg=True, eeg=False)

File /vf/users/MEGmodules/modules/enigma_meg0.2_extras/enigma_MEG/enigmeg/process_meg.py:553, in load_data(filename)
    552 def load_data(filename):
--> 553     datatype, _ = check_datatype(filename)
    554     dataloader = return_dataloader(datatype)
    555     raw = dataloader(filename, preload=True)

File /vf/users/MEGmodules/modules/enigma_meg0.2_extras/enigma_MEG/enigmeg/process_meg.py:539, in check_datatype(filename)
    537     return 'kit', None
    538 else:
--> 539     raise ValueError('Could not detect datatype')

Remove function from process object

Move the function initialize from csv to outside of the process object. This can just be a function that loads the process object.

def initialize_fromcsv(self, csv_info)

If no emptyroom is present - compensation grade is still checked

ERROR:23490_ses_None:vendor_prep :: 'NoneType' object has no attribute 'compensation_grade'
Traceback (most recent call last):
File "/vf/users/MEGmodules/modules/enigma_meg0.5_extras/enigma_MEG/enigmeg/process_meg.py", line 78, in wrapper
output = function(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/vf/users/MEGmodules/modules/enigma_meg0.5_extras/enigma_MEG/enigmeg/process_meg.py", line 447, in vendor_prep
if self.raw_eroom.compensation_grade != 3:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'compensation_grade'
Traceback (most recent call last):
File "/vf/users/MEGmodules/modules/enigma_meg0.5/bin/process_meg.py", line 7, in
exec(compile(f.read(), file, 'exec'))
File "/vf/users/MEGmodules/modules/enigma_meg0.5_extras/enigma_MEG/enigmeg/process_meg.py", line 1403, in
process_subject(args.subject, args) # process the single specified subject
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/vf/users/MEGmodules/modules/enigma_meg0.5_extras/enigma_MEG/enigmeg/process_meg.py", line 1134, in process_subject
proc.do_proc_allsteps()
File "/vf/users/MEGmodules/modules/enigma_meg0.5_extras/enigma_MEG/enigmeg/process_meg.py", line 836, in do_proc_allsteps
self.vendor_prep()
File "/vf/users/MEGmodules/modules/enigma_meg0.5_extras/enigma_MEG/enigmeg/process_meg.py", line 78, in wrapper
output = function(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/vf/users/MEGmodules/modules/enigma_meg0.5_extras/enigma_MEG/enigmeg/process_meg.py", line 447, in vendor_prep
if self.raw_eroom.compensation_grade != 3:

enigma_QA_prep

Code doesn't seem to work for the CAMCAN or MOUS datasets

Initalization - Logfile Parse

Read previous logfile
Parse the last time
Readout all of the subject status items into a dictionary
During subject initialization - reference the history dictionary to pull status and initialize button color

Make the -subjects_dir and -fs_subject combination actually work

Users can specify a freesurfer directory not in BIDS_ROOT/derivatives/freesurfer/subjects if their subjects have already been processed using FreeSurfer. In this case, it is quite likely that the BIDS subject ID (which is always appended with sub-, as in sub-Sub01) is different from the Freesurfer subject ID (which is most likely Sub01, using the prior example). We should make this combination of options work. At the moment, it doesn't. This would involve changes to both process_meg.py and enigma_prep_QA.py

Add functionality to loop over entire BIDS tree

Need to loop over entire tree rather than call for individual subjects. Should this be in a multi processing pool? And there will need to be handling of BIDS trees that have more than one run/session per subject, or meg and anat in different sessions. Write separate function to handle different scenarios.

Verify single parcellation in group data

In compile_alpha_hist_plots (to be renamed) - provide a parc file from fsaverage. Remove any labels in dataframe that are not part of the current parc (eg. aparc vs aparc_sub).

Initialize QA dir upon object creation

If the ENIGMA_MEG_QA is not created - mkdir it.

(enigma_meg_test) jstout@kani:/fast/ENIGMA_OHBM$ ~/src/enigma_MEG/enigmeg/QA/Run_enigma_QA_GUI.py -bids_root $(pwd) -QAtype 'bem'
Traceback (most recent call last):
  File "/home/jstout/src/enigma_MEG/enigmeg/QA/Run_enigma_QA_GUI.py", line 82, in <module>
    history_log = initialize(bids_root, QAtype)        
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jstout/src/enigma_MEG/enigmeg/QA/enigma_QA_GUI_functions.py", line 170, in initialize
    logging.basicConfig(filename=logfile, encoding='utf-8', level=logging.INFO, 
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jstout/miniconda3/envs/enigma_meg_test/lib/python3.11/logging/__init__.py", line 2050, in basicConfig
    h = FileHandler(filename, mode,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jstout/miniconda3/envs/enigma_meg_test/lib/python3.11/logging/__init__.py", line 1181, in __init__
    StreamHandler.__init__(self, self._open())
                                 ^^^^^^^^^^^^
  File "/home/jstout/miniconda3/envs/enigma_meg_test/lib/python3.11/logging/__init__.py", line 1213, in _open
    return open_func(self.baseFilename, self.mode,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/fast/ENIGMA_OHBM/derivatives/ENIGMA_MEG_QA/bem_QA_logfile.txt'

Make a QA list to query

  • QA list will be empty
  • Upon review - the classification will be unchecked
  • After the next/final button is selected - change to good/bad
  • Write good/bad to QA text file

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.