repo_name stringlengths 6 97 | path stringlengths 3 341 | text stringlengths 8 1.02M |
|---|---|---|
dongmengshi/easylearn | eslearn/GUI/lc_ui2py_for_main.py | import os
cmd_str = r'pyuic5 -o easylearn_main_gui.py D:\My_Codes\easylearn-fmri\eslearn\GUI\easylearn_main_gui.ui'
os.system(cmd_str)
|
dongmengshi/easylearn | eslearn/utils/lc_transform1D.py | <reponame>dongmengshi/easylearn<filename>eslearn/utils/lc_transform1D.py
# utf-8
"""
read .1D file
"""
import os
import pandas as pd
import numpy as np
from lc_read_write_Mat import write_mat
def read_1D(file_path):
"""
Transform the .1D file to .mat file
TODO: to other file type
Args:
file_path: .1D file pa... |
dongmengshi/easylearn | eslearn/GUI/easylearn_logger.py | <gh_stars>0
import logging
from logging import handlers
def easylearn_logger(out_name=None, debug_message="", info_message="", warning_message="", error_message="", critical_message=""):
#初始化logger
logger = logging.getLogger()
#设置日志记录级别
logger.setLevel(logging.INFO)
#fmt设置日志输出格式,datefmt设置 asctim... |
dongmengshi/easylearn | eslearn/visualization/lc_boxplot.py | # -*- coding: utf-8 -*-
"""
箱图
当我们的数据是num_subj*num_var,且有几个诊断组时,我们一般希望把var name作为x,把var value作为y,把诊断组作为hue
来做箱图,以便于观察每个var的组间差异。
此时,用于sns的特殊性,我们要将数据变换未长列的形式。
行数目为:num_subj*num_var。列数目=3,分别是hue,x以及y
input:
data_path=r'D:\others\彦鸽姐\final_data.xlsx'
x_location=np.arange(5,13,1)#筛选数据的列位置
未来改进:封装为类,增加可移植性
@a... |
dongmengshi/easylearn | eslearn/utils/lc_pydicom.py | # -*- coding: utf-8 -*-
"""
Created on Sun May 26 19:02:42 2019
@author: lenovo
"""
import pydicom
import nibabel
import SimpleITK as sitk
def read_nii(filename):
nii = nibabel.nifti1.load(filename)
dataset = nii.get_data()
return dataset
def nii2dcm(dataset, filename):
"""
write dicom filenam... |
dongmengshi/easylearn | eslearn/SSD_classification/Data_Inspection/lc_anova_scip.py | # -*- coding: utf-8 -*-
"""
Created on Sat Dec 28 20:06:03 2019
@author: <NAME>
Email: <EMAIL>
"""
from scipy import stats
from statsmodels.formula.api import ols
from statsmodels.stats.anova import anova_lm
from statsmodels.stats.multicomp import pairwise_tukeyhsd
import warnings
import pandas as pd
warnings.filter... |
dongmengshi/easylearn | eslearn/utils/lc_scaler.py | # -*- coding: utf-8 -*-
"""
Created on Wed Jul 4 14:33:00 2018
@author: lenovo
"""
# import
from sklearn.preprocessing import StandardScaler
from sklearn.preprocessing import MinMaxScaler
# def
def scaler(X, method):
if method == 'StandardScaler':
model = StandardScaler()
stdsc_x = model.fit_tra... |
dongmengshi/easylearn | eslearn/utils/lc_delect_sensitive_info.py | <filename>eslearn/utils/lc_delect_sensitive_info.py
# -*- coding: utf-8 -*-
"""
Created on Wed Nov 28 10:03:49 2018
删除scale中敏感信息
@author: lenovo
"""
import pandas as pd
import numpy as np
d = pd.read_excel(
r'D:\WorkStation_2018\WorkStation_2018_08_Doctor_DynamicFC_Psychosis\Scales\修改表.xlsx')
col = list(d.columns)... |
dongmengshi/easylearn | eslearn/GUI/easylearn_main_gui.py | <reponame>dongmengshi/easylearn
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'D:\My_Codes\easylearn-fmri\eslearn\GUI\easylearn_main_gui.ui'
#
# Created by: PyQt5 UI code generator 5.11.3
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets... |
dongmengshi/easylearn | eslearn/feature_engineering/feature_selection/el_relieff.py | # -*- coding: utf-8 -*-
"""
Created on 2020/03/14
Feature selection: Relief-based feature selection algorithm.
feature_train, label_train, feature_test, n_features_to_select
------
@author: <NAME>
"""
import numpy as np
from skrebate import ReliefF
def relief(feature_train, label_train, feature_test, n_features_to_sel... |
dongmengshi/easylearn | setup.py | #-*- coding:utf-8 -*-
"""
Created on 2020/03/03
------
@author: <NAME>; <NAME>; <NAME>; <NAME>; <NAME>; <NAME>; <NAME>
Email: <EMAIL>; <EMAIL>; <EMAIL>;
<EMAIL>; <EMAIL>; <EMAIL>; <EMAIL>.
"""
from setuptools import setup, find_packages
with open("README.md", "r") as fh:
long_description = fh.re... |
dongmengshi/easylearn | eslearn/utils/lc_add_dcminfo_to_foldername_radiomics.py | <reponame>dongmengshi/easylearn<gh_stars>10-100
# -*- coding: utf-8 -*-
"""
Created on Fri Mar 1 22:30:29 2019
读取dicom文件的信息,并在文件夹名字中添加dicom信息【ID_name_oldname】
@author: <NAME>
"""
import os
import pydicom
class ChangeFolderName():
"""change subjects' folder name"""
def __init__(self):
self.path = r'... |
dongmengshi/easylearn | eslearn/utils/multiprocessing_test.py | <filename>eslearn/utils/multiprocessing_test.py
# -*- coding: utf-8 -*-
"""
Created on Tue Dec 4 22:41:05 2018
@author: lenovo
"""
from concurrent.futures import ThreadPoolExecutor
import time
# 参数times用来模拟网络请求的时间
def get_html(times):
time.sleep(times)
print("get page {}s finished\n".format(times))
re... |
dongmengshi/easylearn | eslearn/SSD_classification/Data_Inspection/lc_preprocess_for_206.py | """
This script is used to transform the 206 dataset into .npy format.
1.Transform the .mat files to one .npy file
2. Give labels to each subject, concatenate at the first column
"""
import sys
sys.path.append(r'D:\My_Codes\LC_Machine_Learning\lc_rsfmri_tools\lc_rsfmri_tools_python')
import numpy as np
import pandas a... |
dongmengshi/easylearn | eslearn/machine_learning/classfication/lc_svc_oneVsRest.py | <gh_stars>0
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 25 14:56:39 2018
multi-class classfication using one vs rest
In practice, one-vs-rest classification is usually preferred,
since the results are mostly similar,
but the runtime is significantly less.
@author: lenovo
"""
from sklearn import datasets
from sklea... |
dongmengshi/easylearn | eslearn/machine_learning/classfication/lc_svc_rfe_cv.py | <filename>eslearn/machine_learning/classfication/lc_svc_rfe_cv.py
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 25 10:52:26 2018
rfe-svm-CV
input:
k=3:k-fold
step=0.1:rfe step
num_jobs=1: parallel
scale_method='StandardScaler':standardization method
pca_... |
dongmengshi/easylearn | eslearn/GUI/easylearn_feature_engineering_gui.py | # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'D:/My_Codes/easylearn-fmri/eslearn/GUI/easylearn_feature_engineering_gui.ui'
#
# Created by: PyQt5 UI code generator 5.11.3
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWi... |
dongmengshi/easylearn | eslearn/visualization/lc_barplot.py | # -*- coding: utf-8 -*-
"""
Created on Wed Nov 28 19:12:26 2018
bar plot
当我们的数据是num_subj*num_var,且有几个诊断组时,
我们一般希望把var name作为x,把var value作为y,把诊断组作为hue
来做bar,以便于观察每个var的组间差异。
此时,用于sns的特殊性,我们要将数据变换未长列的形式。
行数目为:num_subj*num_var。列数目=3,分别是hue,x以及y
input:
data_path=r'D:\others\彦鸽姐\final_data.xlsx'
x_location=np.arang... |
dongmengshi/easylearn | eslearn/feature_engineering/pipeline/grid_search_cv/plot_compare_reduction.py | <reponame>dongmengshi/easylearn<gh_stars>0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
=================================================================
Selecting dimensionality reduction with Pipeline and GridSearchCV
=================================================================
This example constructs a pi... |
dongmengshi/easylearn | eslearn/visualization/plot_brainmap_nilearn_.py | <gh_stars>10-100
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 25 22:49:33 2019
@author: <NAME>
Email: <EMAIL>
"""
"""
Making a surface plot of a 3D statistical map
=============================================
project a 3D statistical map onto a cortical mesh using
:func:`nilearn.surface.vol_to_surf`. Display a sur... |
dongmengshi/easylearn | eslearn/examples/demo_pca_rfecv_svc.py | """
This script is a demo script, showing how to use eslearn to training and testing a SVC model.
Classifier: linear SVC
Dimension reduction: PCA
Feature selection: RFE
"""
import numpy as np
import eslearn.machine_learning.classfication.pca_rfe_svc_cv as pca_rfe_svc
# ================================================... |
dongmengshi/easylearn | eslearn/examples/demo_pca_relieff_svc.py | """
This script is a demo script, showing how to use eslearn to training and testing a SVC model.
Classifier: linear SVC
Dimension reduction: PCA
Feature selection: ReliefF
"""
import numpy as np
import eslearn.machine_learning.classfication.pca_relieff_svc_cv as pca_relieff_svc
# =====================================... |
dongmengshi/easylearn | eslearn/machine_learning/datasets/h5py_test.py | # -*- coding: utf-8 -*-
"""
Created on Tue Jul 3 09:12:14 2018
@author: lenovo
"""
#创建
import h5py
#要是读取文件的话,就把w换成r
f=h5py.File("myh5py.hdf5","w")
d1=f.create_dataset("dset1", (20,), 'i')
for key in f.keys():
print(key)
print(f[key].name)
print(f[key].shape)
print(f[key].value)
## 赋值
import h5py
... |
dongmengshi/easylearn | eslearn/utils/regression/multi_test2.py | <gh_stars>0
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 14 20:25:12 2018
@author: lenovo
"""
def func(msg):
print (multiprocessing.current_process().name + '-' + msg)
if __name__ == "__main__":
pool = multiprocessing.Pool(processes=4) # 创建4个进程
for i in range(10):
msg = "hello %d" %(i)
... |
dongmengshi/easylearn | eslearn/utils/lc_rfe_svc_deterministic_train_and_test_dataset.py | <reponame>dongmengshi/easylearn
# -*- coding: utf-8 -*-
"""
Created on Fri Apr 12 11:15:59 2019
@author: lenovo
"""
from lc_featureSelection_rfe import rfeCV
from lc_read_nii import read_sigleNii_LC
from lc_read_nii import main
import numpy as np
from sklearn import datasets
import sys
sys.path.append(r'F:\黎超\dynamic... |
dongmengshi/easylearn | eslearn/statistical analysis/lc_anova_test.py | # -*- coding: utf-8 -*-
"""
Created on Wed Nov 28 15:33:53 2018
@author: lenovo
"""
import numpy as np
import statsmodels.api as sm
import statsmodels.formula.api as smf
from statsmodels.formula.api import ols
dat = sm.datasets.get_rdataset("Guerry", "HistData").data
moore = sm.datasets.get_rdataset("Moore", "... |
dongmengshi/easylearn | eslearn/GUI/easylearn_machine_learning_gui.py | <filename>eslearn/GUI/easylearn_machine_learning_gui.py
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'D:/My_Codes/easylearn-fmri/eslearn/GUI/easylearn_machine_learning_gui.ui'
#
# Created by: PyQt5 UI code generator 5.11.3
#
# WARNING! All changes made in this file will be lost!
from P... |
dongmengshi/easylearn | eslearn/GUI/easylearn_feature_engineering.py | <filename>eslearn/GUI/easylearn_feature_engineering.py
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'D:/My_Codes/easylearn-fmri/eslearn/GUI/Feature_engineering.ui'
#
# Created by: PyQt5 UI code generator 5.11.3
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import ... |
dongmengshi/easylearn | eslearn/machine_learning/regression/lc_cca.py | <reponame>dongmengshi/easylearn<gh_stars>10-100
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 3 14:17:50 2018
典型相关分析
please refer to {Linked dimensions of psychopathology and
connectivity in functional brain networks}
@author: <NAME>
"""
from sklearn.cross_decomposition import CCA
import numpy as np
class LcCCA():... |
dongmengshi/easylearn | eslearn/GUI/__init__.py | name = "easylearn" |
dongmengshi/easylearn | eslearn/machine_learning/test/gcn_test_.py | import torch
from torch_geometric.nn import MessagePassing
from torch_geometric.utils import add_self_loops, degree
from torch_geometric.nn import GCNConv
class GCNConv(MessagePassing):
def __init__(self, in_channels, out_channels):
super(GCNConv, self).__init__(aggr='add') # "Add" aggregation.
s... |
dongmengshi/easylearn | eslearn/utils/lc_read_dicominfo_grouplevel.py | <reponame>dongmengshi/easylearn
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 5 15:30:50 2019
@author: lenovo
"""
import sys
import os
homedir = os.path.dirname(os.path.dirname(__file__))
sys.path.append(homedir)
from os import listdir
from os.path import join
import multiprocessing
from concurrent.futures import Th... |
dongmengshi/easylearn | eslearn/machine_learning/classfication/lc_elasticNet.py | <gh_stars>0
# -*- coding: utf-8 -*-
"""
Created on Tue Dec 18 18:27:38 2018
ElasticNet
Minimizes the objective function:
1 / (2 * n_samples) * ||y_train - Xw||^2_2+ alpha * l1_ratio * ||w||_1
+ 0.5 * alpha * (1 - l1_ratio) * ||w||^2_2
l1_ratio = 1 is the lasso penalty
a * L1 + b * L2
where:
alpha = a + b ... |
dongmengshi/easylearn | test/matlab_engine.py | import matlab.engine
eng = matlab.engine.start_matlab()
[uni_label_of_from_atalas, max_prop, matching_idx] = eng.lc_mapping_brain_atalas_highlevel(nargout=3)
print(matching_idx) |
dongmengshi/easylearn | eslearn/visualization/lc_polarplot.py | # -*- coding: utf-8 -*-
"""
Created on Thu Nov 29 18:39:53 2018
polar bar
@author: lenovo
"""
from pyecharts import Polar
radius1 =['Left orbital frontal cortex',
'Right orbital frontal cortex',
'Left dorsolateral prefrontal cortex',
'Left angular gyrus']
radius2 =['Right primary somatose... |
dongmengshi/easylearn | eslearn/feature_engineering/feature_selection/el_rfe.py | <filename>eslearn/feature_engineering/feature_selection/el_rfe.py
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 11 16:06:48 2018
Recursive feature elimination (RFE) and RFE-Cross-validation(nested)
@author: <NAME>
"""
from sklearn.feature_selection import RFE
#from sklearn.linear_model import LinearRegression
from sk... |
dongmengshi/easylearn | eslearn/machine_learning/classfication/lc_anova_svm.py | # -*- coding: utf-8 -*-
"""
Created on Wed Jul 11 16:43:03 2018
anova for feature selection and svm for classfication
@author: <NAME> (0.7279411764705882, 0.66, 0.79, 0.8419117647058824)
(0.7132352941176471, 0.66, 0.76, 0.8380190311418685)
"""
import sys
import os
root = os.path.dirname(os.path.dirname(os.path.dirname(... |
dongmengshi/easylearn | eslearn/visualization/lc_circleBarPlot.py | <filename>eslearn/visualization/lc_circleBarPlot.py<gh_stars>10-100
# -*- coding: utf-8 -*-
"""
Created on Sat Nov 3 22:17:07 2018
@author: lenovo
"""
from collections import OrderedDict
from math import log, sqrt
import numpy as np
import pandas as pd
from six.moves import cStringIO as StringIO
from bokeh.plotting... |
dongmengshi/easylearn | eslearn/GUI/lc_ui2py_for_data_loading.py | import os
cmd_str = r'pyuic5 -o easylearn_data_loading_gui.py D:\My_Codes\easylearn-fmri\eslearn\gui_test\easylearn_data_loading_gui.ui'
os.system(cmd_str)
|
dongmengshi/easylearn | eslearn/machine_learning/classfication/lc_permutation_svc_multiprocessing.py | # -*- coding: utf-8 -*-
"""
Created on Wed Aug 1 14:53:28 2018
@author: lenovo
"""
import multiprocessing
import time
#from scipy import io
import sys
sys.path.append(r'D:\myCodes\LC_MVPA\Python\MVPA_Python\utils')
# import module
from lc_read_write_Mat import write_mat
import time,os
import numpy as np
import lc_... |
dongmengshi/easylearn | eslearn/statistical analysis/lc_binomialtest.py | # -*- coding: utf-8 -*-
"""
Created on Sun Nov 10 12:39:48 2019
This script is used to perform binomial test for classification performances, e.g., accuracy, sensitivity, specificity.
@author: lenovo
"""
from scipy.special import comb
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
def lc_binomia... |
dongmengshi/easylearn | eslearn/visualization/tmp.py | <gh_stars>10-100
# -*- coding: utf-8 -*-
"""
Created on Sat Nov 2 20:39:06 2019
@author: lenovo
"""
from scipy import io
x = io.loadmat(r'D:\WorkStation_2018\WorkStation_dimensionPLS\Data\ROISignals\ROICorrelation_FisherZ_ROISignal_00003.mat')
x = x['ROICorrelation_FisherZ']
f, (ax) = plt.subplots(figsize=(20,20))
... |
dongmengshi/easylearn | eslearn/statistical analysis/lc_ttest2.py | <reponame>dongmengshi/easylearn
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 27 18:55:25 2018
t test
method='independent'
OR
method='related'
@author: lenovo
"""
from scipy.stats import ttest_ind
from scipy.stats import ttest_rel
import numpy as np
#
def ttest2(a,b,method='independent'):
if method=='independen... |
dongmengshi/easylearn | eslearn/utils/lc_screening_subject_folder_V2.py | # -*- coding: utf-8 -*-
"""
Created on Fri Nov 23 20:27:50 2018
筛选大表的item和subjects
最后得到诊断为[1,2,3,4],扫描质量良好,而且不重复的被试
inputs:
file_all:大表
basicIndex_iloc=[0,11,19,20,21,22,23,27,28,29,30]:基本信息列
basicIndex_str=['学历(年)','中国人利手量表']:基本信息名
hamd17Index_iloc=np.arange(104,126,1),
hamaIn... |
dongmengshi/easylearn | eslearn/utils/selectSubjID_inScale.py | <gh_stars>10-100
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 29 10:43:28 2018
筛选大表的item和subjects
最后得到诊断为[1,2,3,4],扫描质量良好,而且不重复的被试
outputs:
folder:筛选出来的ID
basic:筛选出来的基本信息
hamd17,hamm,yars,bprs:筛选出来的量表
logicIndex_scale:量表的逻辑index
logicIndex_repeat:重复量表的index
@author: lenovo
"""
... |
dongmengshi/easylearn | eslearn/statistical analysis/lc_anova.py | # -*- coding: utf-8 -*-
"""
Created on Tue Nov 27 15:40:45 2018
方差分析
@author: lenovo
"""
import scipy.stats as stats
def oneway_anova(data, *args, **kwargs):
"""
Data is a list,
in which each element is a np.array matrix
(such as N*M, N=sample size, M=number of variable)
"""
f, p = stats.f_one... |
dongmengshi/easylearn | eslearn/utils/copy_file_to_folder.py | <filename>eslearn/utils/copy_file_to_folder.py<gh_stars>0
# -*- coding: utf-8 -*-
"""
Created on Fri Mar 22 20:46:52 2019
将一个文件夹中的ROI文件复制到相应的被试文件夹下面
@author: lenovo
"""
import os
import shutil
import pandas as pd
"""input"""
file_folder_path = r"D:\dms-lymph-nodes\merge_noContrast"
out_folder_path = r"D:\dms-lymph-node... |
dongmengshi/easylearn | eslearn/machine_learning/test/GCNNCourseCodes/myutils.py | <gh_stars>0
"""
@author: <NAME>
LITIS Lab, Rouen, France
<EMAIL>
"""
import numpy as np
from scipy.io import loadmat
import networkx as nx
import numpy.linalg as linalg
from sklearn.preprocessing import StandardScaler
def loadCobraData(fname='cobradat.mat'):
# read mat file
mat = loadmat(fname)
# make A... |
dongmengshi/easylearn | eslearn/utils/lc_selectFile.py | # -*- coding: utf-8 -*-
"""
Created on Wed Jul 18 15:01:44 2018
used for select target files
refer to and thank [https://www.jianshu.com/p/91453c76dbc3]
@author: <NAME>
"""
# import
from nipype import SelectFiles, Node
# def
def selectFile(rootPath=r'I:\Data_Code\Doctor\RealignParameter'):
templates = {'path': '{... |
dongmengshi/easylearn | eslearn/machine_learning/classfication/lc_classify_FC.py | <reponame>dongmengshi/easylearn
# -*- coding: utf-8 -*-
"""
Created on Fri Dec 14 22:15:54 2018
1.以功能连接/动态功能连接矩阵为特征,来进行分类
2.本程序使用的算法为svc(交叉验证)
3.当特征是动态连接时,使用标准差或者均数等来作为特征。也可以自己定义
4.input:
所有人的.mat FC/dFC
5.output:
机器学习的相应结果,以字典形式保存再result中。
@author: <NAME>
"""
import sys
sys.path.append(
r'D:\My_Codes\LC_... |
dongmengshi/easylearn | eslearn/utils/lc_copy_selected_file_V4.py | # -*- coding: utf-8 -*-
"""
Created on Thu Aug 30 13:05:28 2018:
在版本3的基础上,根据pandas的join方法来求交集
根据从量表中筛选的样本,来获得符合要求的原始数据的路径
数据结构neuroimageDataPath//subject00001//files
也可以是任何的数据结构,只要给定subjName在哪里就行
总之,最后把file复制到其他地方(可以限定某个file)
input:
# 1 referencePath:需要复制的被试名字所在text文件(大表中的folder)
# 2 regularExpressionOfsu... |
dongmengshi/easylearn | eslearn/utils/lc_meanFD_compare.py | <filename>eslearn/utils/lc_meanFD_compare.py
# -*- coding: utf-8 -*-
"""
Created on Mon May 20 21:33:44 2019
@author: lichao
"""
import sys
sys.path.append(r'F:\黎超\dynamicFC\Code\lc_rsfmri_tools_python')
import pandas as pd
from Statistics.lc_anova import oneway_anova
class CompareMean(object):
"""compare the me... |
dongmengshi/easylearn | eslearn/utils/lc_match_maskVSorigin.py | <reponame>dongmengshi/easylearn
# utf-8
"""
Author: <NAME>
Email: <EMAIL>
For: Radiomics
Useage: 将原始series(underlay, dicomfile)与ROI(mask/overlay)对应起来
INPUT: root_roi and root_origin
ROI:
/root_roi
/06278717_WANGTIEHAN_R03855066_S1_Merge
/ROI_1
/06278717_WANG... |
dongmengshi/easylearn | eslearn/utils/extract_roi160info.py | # -*- coding: utf-8 -*-
"""
Created on Sat Jul 6 19:57:57 2019
@author: lenovo
"""
import numpy as np
import pandas as pd
# roi 2 net
with open(r'F:\Data\ASD\ROI_160.txt', 'r') as f:
info = f.readlines()
info = pd.Series(info)
# roi
roi = info.str.findall('\d.*[a-zA-Z]*\d')
roi = pd.Series([rn[0] for rn in ro... |
dongmengshi/easylearn | eslearn/utils/el_call_powershell.py | """ Call PowerShell
This class is copy from scapy
"""
import os
from glob import glob
import subprocess as sp
class PowerShell:
def __init__(self, coding, ):
cmd = [self._where('PowerShell.exe'),
"-NoLogo", "-NonInteractive", # Do not print headers
"-Command", "-"] # Li... |
dongmengshi/easylearn | eslearn/machine_learning/parallel_processing/lc_parallelCompute.py | <filename>eslearn/machine_learning/parallel_processing/lc_parallelCompute.py
# -*- coding: utf-8 -*-
"""
Created on Sun Jul 1 19:47:54 2018
@author: lenovo
"""
#from joblib import Parallel, delayed
import time
import numpy as np
from math import sqrt
# small data
%time result1 = Parallel(n_jobs=1)(delayed(sqrt)(i**2)... |
dongmengshi/easylearn | eslearn/SSD_classification/Stat/lc_describe_info_feu.py | # -*- coding: utf-8 -*-
"""
Created on Sat Mar 14 17:03:05 2020
This code is used to describe information for first episode unmedicated SSD
@author: lenovo
"""
import pandas as pd
info_file = r'D:\WorkStation_2018\SZ_classification\Scale\cov_unmedicated_sp_and_hc_550.txt'
scale_file = r'D:\WorkStation_2018\SZ_classifi... |
dongmengshi/easylearn | eslearn/utils/lc_splitX_accord_sorted_y.py | <reponame>dongmengshi/easylearn
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 11 21:07:53 2018
@author: lenovo
"""
import numpy as np
def splitX_accord_sorted_y(y, k):
if y.shape[0] == 1:
y = y.reshape(y.shape[1], 0)
ind_y_sorted = np.argsort(y, axis=0) # ascending
ind_one_fold = []
ind_ori... |
dongmengshi/easylearn | eslearn/visualization/lc_scatterplot.py | <reponame>dongmengshi/easylearn<gh_stars>10-100
# -*- coding: utf-8 -*-
"""
Created on Tue Jul 3 15:29:02 2018
sns.set(stynamele='ticks', palette='muted', color_codes=True, font_scale=1.5)
sns.set_stynamele('dark')
主题 stynamele:darkgrid, whitegrid, dark, white, ticks,默认为darkgrid。
sns.set_palette:deep, muted, bright, p... |
dongmengshi/easylearn | eslearn/machine_learning/test/gcn_test_1.py | <filename>eslearn/machine_learning/test/gcn_test_1.py
"""
https://blog.csdn.net/skj1995/article/details/103780873
"""
import os.path as osp
import scipy.io as sio
import numpy as np
import torch
import torch.nn.functional as F
from torch_geometric.datasets import TUDataset
from torch_geometric.data import DataLoader
fr... |
dongmengshi/easylearn | eslearn/visualization/lc_bar_plot_for_fc.py | # -*- coding: utf-8 -*-
"""
Created on Fri May 31 17:01:21 2019
@author: lenovo
"""
import sys
import os
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sys.path.append(
r'D:\My_Codes\LC_Machine_Learning\lc_rsfmri_tools\lc_rsfmri_tools_python')
from Utils.lc_read_write_... |
dongmengshi/easylearn | eslearn/utils/lc_selectFile_permSVC.py | # -*- coding: utf-8 -*-
"""
Created on Tue Jul 31 15:07:39 2018
@author: lenovo
"""
# import
from nipype import SelectFiles, Node
# def
def selectFile(rootPath=r'D:\其他\老舅财务\allData'):
templates = {'path': '*.mat'}
# Create SelectFiles node
sf = Node(SelectFiles(templates),
name='selectfile... |
dongmengshi/easylearn | eslearn/machine_learning/test/easylearn_logger.py | # -*- coding: utf-8 -*-
"""
Created on Fri Apr 3 20:07:19 2020
https://zhuanlan.zhihu.com/p/78452993
@author: lenovo
"""
import torch
from torch.nn import Sequential as Seq, Linear as Lin, ReLU
from torch_geometric.nn import MessagePassing
from torch_geometric.datasets import TUDataset
# dataset = TUDataset(roo... |
dongmengshi/easylearn | eslearn/visualization/lc_violinplot_yg.py | # -*- coding: utf-8 -*-
"""
Created on Mon Nov 19 22:21:27 2018
小提琴图:把升高的脑区和降低的脑区分开做小提琴图
增加的脑区:
x_location=np.arange(13,17,1)
减低的脑区
x_location=np.arange(5,13,1)
@author: lenovo
"""
import sys
sys.path.append(r'D:\myCodes\MVPA_LIChao\MVPA_Python\plot')
import lc_violinplot as violinplot
import lc_barplot as bar... |
dongmengshi/easylearn | eslearn/utils/download_fcon1000_clinicaldata.py | # -*- coding: utf-8 -*-
"""
Created on Thu Jul 4 20:47:55 2019
# download clinical info of fcon1000
# Author: <NAME>
"""
import os
import urllib
def get_sitename():
"""
get all site name
"""
root_dir = r'F:\Data\fcon_1000'
sitename = os.listdir(root_dir)
return sitename
def get_url(sitename):
"""
get a... |
dongmengshi/easylearn | eslearn/GUI/easylearn_machine_learning_run.py | # -*- coding: utf-8 -*-
"""The GUI of the machine_learning module of easylearn
Created on 2020/04/15
@author: <NAME>
Email:<EMAIL>
GitHub account name: lichao312214129
Institution (company): Brain Function Research Section, The First Affiliated Hospital of China Medical University, Shenyang, Liaoning, PR China.
@au... |
dongmengshi/easylearn | eslearn/stylesheets/PyQt5_stylesheets/PyQt5_stylesheets/pyqt5_style_Classic_rc.py | # -*- coding: utf-8 -*-
# Resource object code
#
# Created by: The Resource Compiler for PyQt5 (Qt v5.11.2)
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore
qt_resource_data = b"\
\x00\x00\x05\xbe\
\x74\
\x61\x62\x57\x69\x64\x67\x65\x74\x7b\x0d\x0a\x20\x20\x20\x20\x66\
\x6f\x6e\x74\x... |
dongmengshi/easylearn | eslearn/utils/lc_screening_subject_folder_V3.py | # -*- coding: utf-8 -*-
"""
Created on Sun Nov 25 21:53:10 2018
改自selectSubjID_inScale_V2
根据给定的条件筛选大表的item和subjects' folder
inputs:
file_all:大表
column_basic1=[0,11,19,20,21,22,23,27,28,29,30]:基本信息列
column_basic2=['学历(年)','中国人利手量表']:基本信息名
column_hamd17=np.arange(104,126,1),
col... |
dongmengshi/easylearn | eslearn/utils/lc_copy_selected_file_V5.py | <filename>eslearn/utils/lc_copy_selected_file_V5.py
# -*- coding: utf-8 -*-
"""
Created on Thu Aug 30 13:05:28 2018:
在版本3的基础上,根据pandas的join方法来求交集
根据从量表中筛选的样本,来获得符合要求的原始数据的路径
数据结构neuroimageDataPath//subject00001//files
也可以是任何的数据结构,只要给定subjName在哪里就行
总之,最后把file复制到其他地方(可以限定某个file)
input:
#1 referencePath:需要复制的被试名字所... |
dongmengshi/easylearn | eslearn/utils/lc_featureSelection_variance.py | <filename>eslearn/utils/lc_featureSelection_variance.py
# -*- coding: utf-8 -*-
"""
Created on Tue Jul 24 14:38:20 2018
dimension reduction with VarianceThreshold using sklearn.
Feature selector that removes all low-variance features.
@author: lenovo
"""
from sklearn.feature_selection import VarianceThreshold
import nu... |
dongmengshi/easylearn | eslearn/utils/lc_read_dicominfo_subjlevel.py | <filename>eslearn/utils/lc_read_dicominfo_subjlevel.py
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 5 15:30:50 2019
This script is used to read dicom informations from one subject which contains several series folders.
@author: lenovo
"""
import sys
import os
import numpy
homedir = os.path.dirname(os.getcwd())
sys.... |
dongmengshi/easylearn | eslearn/SSD_classification/ML/lc_pca_svc_pooling.py | <reponame>dongmengshi/easylearn
# -*- coding: utf-8 -*-
"""
Created on 2019/11/20
This script is used to training a linear svc model using training dataset,
and test this model using test dataset with pooling cross-validation stratage.
All datasets (4 datasets) were concatenate into one single dataset, then using cr... |
dongmengshi/easylearn | eslearn/visualization/lc_test_circle.py |
# Authors: <NAME> <<EMAIL>>
# <NAME> <<EMAIL>>
# <NAME> <<EMAIL>>
#
# License: Simplified BSD
import numpy as np
import pytest
import matplotlib.pyplot as plt
from mne.viz import plot_connectivity_circle, circular_layout
def test_plot_connectivity_circle():
"""Test plotting connectivity circ... |
dongmengshi/easylearn | eslearn/utils/lc_financial.py | <filename>eslearn/utils/lc_financial.py
# -*- coding: utf-8 -*-
"""
Created on Fri Jul 13 16:14:22 2018
财务
@author: lenovo
"""
# import
import pandas as pd
import numpy as np
# input
textFile = r'I:\其他文件\老舅财务\李锰等\201702\201702-1.txt'
targetName = '张华'
targetItem = ['户名', '帐号', '交易日期', '摘要',
'借贷标志', '交易金额'... |
dongmengshi/easylearn | eslearn/utils/el_create_random_balanced_sequence.py | <filename>eslearn/utils/el_create_random_balanced_sequence.py
# -*- coding: utf-8 -*-
"""
Created on Fri Mar 13 07:50:18 2020
@author: <NAME>
Email: <EMAIL>
"""
import numpy as np
import time
class CreateSequence(object):
"""
This class is used to create random and balanced sequences for k stimulations
Th... |
dongmengshi/easylearn | eslearn/machine_learning/classfication/lc_svc_rfe_cv_byYourSelf.py | <reponame>dongmengshi/easylearn
# -*- coding: utf-8 -*-
"""
Created on Wed self.decision 5 21:12:49 2018
自定义训练集和测试集,进行训练和测试
rfe-svm-CV
input:
k=3:k-fold
step=0.1:rfe step
num_jobs=1: parallel
scale_method='StandardScaler':standardization method
pca_n_com... |
dongmengshi/easylearn | eslearn/preprocessing.py | def data_preprocess(sel, feature_train, feature_test, data_preprocess_method, data_preprocess_level):
'''
This function is used to preprocess features
Method 1: preprocess data in group level, one feature by one feature.
Method 2: preprocess data in subject level.
'''
# M... |
dongmengshi/easylearn | eslearn/utils/lc_group_all_dcm_accordingto_series_radiomics.py | <reponame>dongmengshi/easylearn<filename>eslearn/utils/lc_group_all_dcm_accordingto_series_radiomics.py
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 6 18:10:18 2019
@author: lenovo
"""
import sys
sys.path.append(r'F:\黎超\dynamicFC\Code\lc_rsfmri_tools_python-master\Utils')
import os
import numpy as np
import nibabel... |
dongmengshi/easylearn | eslearn/GUI/el_logger.py | import logging
from logging import handlers
def logger():
#初始化logger
logger = logging.getLogger()
#设置日志记录级别
logger.setLevel(logging.INFO)
#fmt设置日志输出格式,datefmt设置 asctime 的时间格式
formatter = logging.Formatter(fmt='[%(asctime)s]%(levelname)s:%(message)s',
datefmt... |
dongmengshi/easylearn | eslearn/utils/download_asd.py | <reponame>dongmengshi/easylearn
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 4 20:47:55 2019
@author: lenovo
"""
# download_abide_preproc.py
#
# Author: <NAME>, 2015
'''
This script downloads data from the Preprocessed Connetomes Project's
ABIDE Preprocessed data release and stores the files in a local
directory;... |
dongmengshi/easylearn | eslearn/feature_engineering/feature_selection/el_fscore.py | """ Selection features using F-score
Copy form https://www.zealseeker.com/archives/f-score-for-feature-selection-python/
TODO: Extend to multiple-class classification (Refrence: http://www.joca.cn/EN/Y2010/V30/I4/993#)
"""
def fscore_core(np,nn,xb,xbp,xbn,xkp,xkn):
'''
np: number of positive features
nn... |
dongmengshi/easylearn | eslearn/machine_learning/classfication/lc_permutation_svc_njobs_noBlock.py | <filename>eslearn/machine_learning/classfication/lc_permutation_svc_njobs_noBlock.py<gh_stars>0
# -*- coding: utf-8 -*-
"""
Created on Mon Jul 30 14:57:38 2018
permutation test: Parallel elastic net regression
Note.:The program is divided into many blocks
so as to avoid interruption.
input:
fileName=fi... |
dongmengshi/easylearn | eslearn/machine_learning/test/gcn_test.py | <gh_stars>0
import torch
from torch.nn import Linear
import torch.nn.functional as F
from torch_geometric.nn.conv import MessagePassing
from torch_geometric.data import Data
class CGConv(MessagePassing):
r"""The crystal graph convolutional operator from the
`"Crystal Graph Convolutional Neural Networks for an... |
dongmengshi/easylearn | eslearn/utils/lc_split_roi_radiomics.py | # -*- coding: utf-8 -*-
"""
Created on Sat Apr 6 18:10:18 2019
@author: lenovo
"""
from lc_read_nii import save_nii
from lc_read_nii import read_sigleNii_LC
import nibabel as nib
import numpy as np
import os
import sys
sys.path.append(r'D:\My_Codes\LC_Machine_Learning\lc_rsfmri_tools\lc_rsfmri_tools_python\Utils')
f... |
dongmengshi/easylearn | eslearn/machine_learning/regression/lc_permutation_enet.py | # -*- coding: utf-8 -*-
"""
Created on Sat Jul 7 11:18:41 2018
permutation test: Parallel elastic net regression
Note.:The program is divided into many blocks
so as to avoid interruption.
input:
fileName=fileName to save results
@author: <NAME>
"""
# import module
from joblib import Parallel, delayed
... |
dongmengshi/easylearn | eslearn/utils/el_rename_by_replace.py | <reponame>dongmengshi/easylearn
import os
import re
def rename(directory, old_string, new_string):
"""Rename files
This function is used to rename files in a directory by replacing some strings in old nane with new strings.
For example, we want to rename "MVPA_2019_schizophrenia" to "Machine_Learning_2... |
dongmengshi/easylearn | eslearn/utils/tricks.py | # -*- coding: utf-8 -*-
"""
Created on Mon Jul 23 14:12:52 2018
@author: lenovo
"""
#import numpy as np
seq = [1, 2, 3, 5]
# 类似于matlab的@,定义一个函数
def f(x): return pow(x, 3)
f(2)
# lambda配合map来对一个列表遍历求值
myMap = map(f, seq)
print(list(myMap))
# lambda 配合filter函数
result = list(filter(lambda x: x >= 2, seq))
print(resul... |
dongmengshi/easylearn | eslearn/SSD_classification/Visulization/lc_visualizing_performances.py | # -*- coding: utf-8 -*-
"""
This script is used to perform post-hoc analysis and visualization:
the classification performance of subsets (only for Schizophrenia Spectrum: SZ and Schizophreniform).
Unless otherwise specified, all results are for Schizophrenia Spectrum.
"""
#%%
import sys
sys.path.append(r'D:\My_Code... |
dongmengshi/easylearn | eslearn/developer/function_template.py | # -*- coding: utf-8 -*-
""" This module is used to perform dimension reduction
Created on Wed Jul 4 13:57:15 2018
@author: <NAME>
Email:<EMAIL>
GitHub account name: lichao312214129
Institution (company): Brain Function Research Section, The First Affiliated Hospital of China Medical University, Shenyang, Liaoning, PR... |
dongmengshi/easylearn | eslearn/machine_learning/classfication/lc_svc_rfe_cv_excelcsv.py | # -*- coding: utf-8 -*-
"""
For 胜男姐
数据输入格式为excel
svc
@author: <NAME>
"""
import sys
sys.path.append(r'D:\My_Codes\LC_Machine_Learning\lc_rsfmri_tools\lc_rsfmri_tools_python')
import os
import numpy as np
import pandas as pd
# import pickle
from sklearn.preprocessing import LabelEncoder
class SVCForDataFromExcel(objec... |
dongmengshi/easylearn | eslearn/visualization/lc_circleBarPlot2.py | # -*- coding: utf-8 -*-
"""
Created on Sat Nov 3 22:29:21 2018
@author: lenovo
"""
from collections import OrderedDict
from math import log, sqrt
import numpy as np
import pandas as pd
from six.moves import cStringIO as StringIO
from bokeh.plotting import figure, show, output_file
#df=np.abs(pd.DataFrame(np.random... |
dongmengshi/easylearn | eslearn/machine_learning/regression/lc_elasticNet.py | # -*- coding: utf-8 -*-
"""
Created on Sun Jul 1 16:31:20 2018
This is a class of enastic net regression
Refer to {"Individualized Prediction of Reading Comprehension
Ability Using Gray Matter Volume"}
{Elastic net with nesting cross-validationt alpha=lambda l1_ratio=lasso 惩罚系数}
Input:
X: features
y: responses... |
dongmengshi/easylearn | eslearn/utils/coveredPercentage.py | # -*- coding: utf-8 -*-
"""
Created on Wed Sep 12 19:10:02 2018
@author: lenovo
"""
from lc_read_nii import read_sigleNii_LC
import sys
sys.path.append(r'D:\myCodes\LC_MVPA\Python\MVPA_Python\utils')
img_path_3d = r'D:\其他\陈逸凡\aLL_mask3D.nii'
img_path_alff = r'D:\其他\陈逸凡\all_maskALFF.nii'
data_3d = read_sigleNii_LC(img... |
dongmengshi/easylearn | eslearn/statistical analysis/lc_chisqure.py | <reponame>dongmengshi/easylearn
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 26 15:31:57 2018
构成比的卡方检验
Chi-square test of independence of variables in a contingency table.
@author: lenovo
"""
from scipy.stats import chi2_contingency
from scipy.stats import chi2
import numpy as np
def lc_chi2(data):
# data=np.ar... |
dongmengshi/easylearn | eslearn/utils/lc_autopep8.py | # -*- coding: utf-8 -*-
"""
Created on Tue May 7 21:14:51 2019
@author: lenovo
"""
import subprocess
import os
import numpy as np
def my_autopep8(py_name):
cmd = "autopep8 --in-place --aggressive --aggressive" + " " + py_name
print('converting {}...'.format(py_name))
state = subprocess.call(cmd, shell=T... |
dongmengshi/easylearn | eslearn/visualization/lc_ancova.py | # -*- coding: utf-8 -*-
"""
Created on Mon Dec 31 20:03:53 2018
ancova
@author: lenovo
"""
from __future__ import print_function
import statsmodels.api as sm
import statsmodels.formula.api as smf
star98 = sm.datasets.star98.load_pandas().data
formula = 'SUCCESS ~ LOWINC + PERASIAN + PERBLACK + PERHISP + PCTCHRT + \
... |
dongmengshi/easylearn | eslearn/SSD_classification/Data_Inspection/lc_preprocess_for_COBRE.py | <filename>eslearn/SSD_classification/Data_Inspection/lc_preprocess_for_COBRE.py
"""
This script is used to transform the UCLA dataset into .npy format.
1.Transform the .mat files to one .npy file
2. Give labels to each subject, concatenate at the first column
"""
import sys
sys.path.append(r'D:\My_Codes\LC_Machine_Lear... |
dongmengshi/easylearn | eslearn/feature_engineering/feature_preprocessing/el_filter_anova.py | from sklearn.feature_selection import f_classif
def dimReduction_filter(feature_train, label_train, feature_test, p_thrd = 0.05):
"""This function is used to Univariate Feature Selection: ANOVA
"""
f, p = f_classif(feature_train, label_train)
mask_selected = p < p_thrd
... |
dongmengshi/easylearn | eslearn/utils/lc_read_h5py_value.py | # -*- coding: utf-8 -*-
"""
Created on Tue Jul 10 10:03:45 2018
@author: lenovo
"""
# import
import h5py
import numpy as np
# def
def read_h5py_value(file_name='enet', dataset_name='Predict'):
f = h5py.File(file_name + ".hdf5", "a")
value = np.array([])
for g in f.keys():
d = f[g]
value =... |
dongmengshi/easylearn | eslearn/machine_learning/regression/lc_nx.py | # -*- coding: utf-8 -*-
"""
Created on Sat Aug 17 22:21:28 2019
@author: lenovo
"""
import matplotlib.pyplot as plt
import networkx as nx
G=nx.path_graph(400)
G.add_path([10,11,12])
nx.draw(G,with_labels=True,label_size=1000,node_size=1000,font_size=20)
plt.show()
for c in sorted(nx.connected_components(G),key=len,r... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.