Skip to main content

This project is designed for machine learning in resting-state fMRI field

Project description

Make machine learning easy!

Easylearn is designed for machine learning mainly in resting-state fMRI, radiomics and other fields (such as EEG). Easylearn is built on top of scikit-learn, pytorch and other packages. Easylearn can assist doctors and researchers who have limited coding experience to easily realize machine learning, e.g., (MR/CT/PET/EEG)imaging-marker- or other biomarker-based disease diagnosis and prediction, treatment response prediction, disease subtyping, dimensional decoding for transdiagnostic psychiatric diseases or other diseases, disease mechanism exploration and etc.

We focus on machine learning rather than data preprocessing. Many software, such as SPM, GRETNA, DPABI, REST, RESTPlus, CCS, FSL, Freesufer, nipy, nipype, nibabel, fmriprep and etc, can be used for data preprocessing.

Citing information:

If you think this software (or some function) is useful, citing the easylearn software in your paper or code would be greatly appreciated! Citing link: https://github.com/easylearn-fmri/easylearn

GUI preview

Main Interface

Main Window

Data loading Interface

Data loading

Feature engineering Interface (feature preprocessing)

Featur engineering

Feature engineering Interface (dimension reduction)

Featur engineering

Feature engineering Interface (feature selection)

Featur engineering

Feature engineering Interface (unbalance treatment)

Featur engineering

Machine learning Interface

Machine learning

Core Dependencies

The follows will be automatically install if you use "pip install -U easylearn" command

  • sklearn
  • numpy
  • pandas
  • python-dateutil
  • pytz
  • scikit-learn
  • scipy
  • six
  • nibabel
  • imbalanced-learn
  • skrebate
  • matplotlib

Install

pip install -U easylearn

Development

At present, the project is in the development stage. We hope you can join us!
Any contributions you make will be appreciated and announced.
Please refer to developer link for details.

Email: lichao19870617@gmail.com
Wechat: 13591648206

Initiators

Ke Xu
kexu@vip.sina.com  
Brain Function Research Section, The First Affiliated Hospital of China Medical University, Shenyang, Liaoning, PR China.  
Department of Radiology, The First Affiliated Hospital of China Medical University.
Chao Li
lichao19870617@gmail.com
Brain Function Research Section, The First Affiliated Hospital of China Medical University, Shenyang, Liaoning, PR China.  
Mengshi Dong
dongmengshi1990@163.com  
Department of Radiology, The First Affiliated Hospital of China Medical University, Shenyang, Liaoning, PR China.   

Supervisors/Consultants

Yanqing Tang
yanqingtang@163.com  
1 Brain Function Research Section, The First Affiliated Hospital of China Medical
University, Shenyang, Liaoning, PR China.  
2 Department of Psychiatry, The First Affiliated Hospital of China Medical University,
Shenyang, Liaoning, PR China.        
Yong He
yong.he@bnu.edu.cn  
1 National Key Laboratory of Cognitive Neuroscience and Learning, Beijing Normal University, Beijing 100875, China  
2 Beijing Key Laboratory of Brain Imaging and Connectomics, Beijing Normal University, Beijing 100875, China  
3 IDG/McGovern Institute for Brain Research, Beijing Normal University, Beijing 100875, China 

Maintainers

Vacancy 1

Contributors will first add to the contributors_list.md. Once your contribution is important or more than or equal to 1/4 of the total code, we will add you as a maintainer.

Vacancy 2

Contributors will first add to the contributors_list.md. Once your contribution is important or more than or equal to 1/4 of the total code, we will add you as a maintainer.

Contributors

The current contributors are in contributors_list.md. Once your contribution is important or more than or equal to 1/4 of the total code, we will add you as a maintainer.

Curent team members

The current team members are in current_team_members.md. If you contributed your code, please add yourself to the contributor list.

Sponsors

We welcome potential sponsors to sponsor our project! Please contact me for details <Wechat: QQ312214129>

Demo

Although, the GUI is under development, you can use simple commands to accomplish some machine learning tasks.
The simplest demo is in the eslearn/examples.
Below is a demo of training a model to classify insomnia patients using weighted functional connectivity strength as features (You can easily use other voxel-wise metrics as features, such as ReHo, ALFF). This demo use svc as classifier, Principal Component Analysis (PCA) as dimension reduction method and Recursive feature elimination (RFE) as feature selection method (inner cross-validation). In each fold, this program will upper-resampling the training dataset to balance the cases with +1 labels and 0 labels.


import numpy as np
import eslearn.machine_learning.classfication.pca_rfe_svc_cv as pca_rfe_svc

# =============================================================================
# All inputs
path_patients = r'D:\WorkStation_2018\Workstation_Old\WorkStation_2018-05_MVPA_insomnia_FCS\Degree\degree_gray_matter\Zdegree\Z_degree_patient\Weighted'  # All patients' image files, .nii format
path_HC = r'D:\WorkStation_2018\Workstation_Old\WorkStation_2018-05_MVPA_insomnia_FCS\Degree\degree_gray_matter\Zdegree\Z_degree_control\Weighted'  # All HCs' image files, .nii format
path_mask = r'G:\Softer_DataProcessing\spm12\spm12\tpm\Reslice3_TPM_greaterThan0.2.nii'  # Mask file for filter image
path_out = r'D:\WorkStation_2018\Workstation_Old\WorkStation_2018-05_MVPA_insomnia_FCS\Degree\degree_gray_matter\Zdegree'  # Directory for saving results
data_preprocess_method='StandardScaler'
data_preprocess_level='group'  # In which level to preprocess data 'subject' or 'group'
num_of_fold_outer=5  # How many folds to perform cross validation
is_dim_reduction=1  # Whether to perform dimension reduction, default is using PCA to reduce the dimension.
components=0.95   # How many percentages of the cumulatively explained variance to be retained. This is used to select the top principal components.
step=0.1  # RFE parameter: percentages or number of features removed each iteration.
num_fold_of_inner_rfeCV=5  # RFE parameter:  how many folds to perform inner RFE loop.
n_jobs=-1  # RFE parameter:  how many jobs (parallel works) to perform inner RFE loop.
is_showfig_finally=True  # Whether show results figure finally.
is_showfig_in_each_fold=False  # Whether show results in each fold.
# =============================================================================
***
clf = pca_rfe_svc.PcaRfeSvcCV(
        path_patients=path_patients,
        path_HC=path_HC,
        path_mask=path_mask,
        path_out=path_out,
        data_preprocess_method=data_preprocess_method,
        data_preprocess_level=data_preprocess_level,
        num_of_fold_outer=num_of_fold_outer,  # How many folds to perform cross validation (Default: 5-fold cross validation)
        is_dim_reduction=is_dim_reduction,  # Default is using PCA to reduce the dimension.
        components=components, 
        step=step,
        num_fold_of_inner_rfeCV=num_fold_of_inner_rfeCV,
        n_jobs=n_jobs,
        is_showfig_finally=is_showfig_finally,  # Whether show results figure finally.
        is_showfig_in_each_fold=is_showfig_in_each_fold  # Whether show results in each fold.
    )

results = clf.main_function()
results = results.__dict__

print(f"mean accuracy = {np.mean(results['accuracy'])}")
print(f"std of accuracy = {np.std(results['accuracy'])}")
print(f"mean sensitivity = {np.mean(results['sensitivity'])}")
print(f"std of sensitivity = {np.std(results['sensitivity'])}")
print(f"mean specificity = {np.mean(results['specificity'])}")
print(f"std of specificity = {np.std(results['specificity'])}")
print(f"mean AUC = {np.mean(results['AUC'])}")
print(f"std of AUC = {np.std(results['AUC'])}")



If the program runs successfully, some results file will be generated under the results folder (path_out), as follows:

Classification performances

Classification performances


Classification performances (text, each row are results of one fold of the 5-fold cross-validation)

wei


Classfication weights (top 1%, BrainNet Viewer)

Top classfication weights

Predicted decision, predicted label and real label

Predicted decision, predicted label and real label

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

easylearn-0.1.20a0.tar.gz (1.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

easylearn-0.1.20a0-py3-none-any.whl (1.4 MB view details)

Uploaded Python 3

File details

Details for the file easylearn-0.1.20a0.tar.gz.

File metadata

  • Download URL: easylearn-0.1.20a0.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8

File hashes

Hashes for easylearn-0.1.20a0.tar.gz
Algorithm Hash digest
SHA256 92c110235b31d83ab03108485bf9e234a47a43169ac1158cd0992c6ee89938d1
MD5 dc58f8c19778e3c8a3f776549b93abef
BLAKE2b-256 3f7456029408cae23402393f8cfeba70609574e6bb0dfef62965b8a9e3d85d81

See more details on using hashes here.

File details

Details for the file easylearn-0.1.20a0-py3-none-any.whl.

File metadata

  • Download URL: easylearn-0.1.20a0-py3-none-any.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8

File hashes

Hashes for easylearn-0.1.20a0-py3-none-any.whl
Algorithm Hash digest
SHA256 a699e5aecfeff2fa7211dc2e3e3620a3e5dc5e3e6a628246b89236ad52d1476a
MD5 d1995a37815b2d721add971e287f5a29
BLAKE2b-256 b357d0908b854c3362aa559b94f7d7e425a5d84e6b865648862462aba325b8e3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page