Autism spectrum disorder identification using machine learning models on MRI data.
The 11 matches
- [1] § Results and discussion ↔ notebooks/Cross_validation_Sun_MRI .ipynb, lines 592–679 · score 0.75 · fold Cross Validation, ROC AUC, ensemble model, voting, proxy, Stratified
- [2] § Results and discussion ↔ notebooks/Suni_Final_MRI.ipynb, lines 1298–1391 · score 0.74 · fold Cross Validation, ROC AUC, ensemble model, voting, proxy, Stratified
- [3] § Materials and, ethods › Data sources ↔ datasets/preprocessed_datasets/preprocessed_pipeline.py, lines 23–26 · score 0.73 · anat_qap.csv, dti_qap.csv, functional_qap.csv, pipeline, preprocessed
- [4] § Materials and, ethods › Data sources ↔ datasets/preprocessed_datasets/preprocessed_pipeline.py, lines 23–26 · score 0.70 · anat_qap.csv, dti_qap.csv, functional_qap.csv, preprocessing
- [5] § Model Training and validation › Deep learning architectures: 1D-CNN and ResNet ↔ notebooks/Cross_validation_Sun_MRI .ipynb, lines 194–312 · score 0.66 · ResNet, blocks, binary, layers, shortcut, Adam
- [6] § Model Training and validation › Deep learning architectures: 1D-CNN and ResNet ↔ notebooks/Suni_Final_MRI.ipynb, lines 185–311 · score 0.64 · ResNet, blocks, binary, layers, shortcut, Adam
- [7] § Materials and, ethods › Feature engineering ↔ notebooks/Suni_Final_MRI.ipynb, lines 1298–1391 · score 0.60 · Feature engineering, crucial, integrity, FD, technical, MIS
- [8] § Model Training and validation › Model validation ↔ notebooks/Cross_validation_Sun_MRI .ipynb, lines 592–679 · score 0.58 · fold Cross Validation, Stratified, ensemble, split, preprocessed, KNN
- [9] § Model Training and validation › Support Vector Machines (SVM) ↔ notebooks/Cross_validation_Sun_MRI .ipynb, lines 315–430 · score 0.58 · GridSearchCV, SVM model, RBF, gamma, kernel, probabilities
- [10] § Model Training and validation › Deep learning architectures: 1D-CNN and ResNet ↔ notebooks/Cross_validation_Sun_MRI .ipynb, lines 130–191 · score 0.55 · dropout, ReLU, activation, softmax, filters, dense
- [11] § Model Training and validation › Deep learning architectures: 1D-CNN and ResNet ↔ notebooks/Suni_Final_MRI.ipynb, lines 122–141 · score 0.54 · dropout, ReLU, activation, softmax, filters, dense
Paper
Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC
The paper is loaded when this pane is shown.
The authors' code
Jupyter notebook · 679 lines · 25 KB · MIT · 5 matches
- # %%
- import pandas as pd
- from google.colab import drive
- drive.mount('/content/drive')
- # %%
- from google.colab import drive
- drive.mount('/content/drive')
- # %%
- !pip install imbalanced-learn scikit-learn tensorflow matplotlib seaborn
- # %%
- import pandas as pd
- import numpy as np
- import pandas as pd
- import matplotlib.pyplot as plt
- import seaborn as sns
- from sklearn.ensemble import RandomForestClassifier
- from sklearn.decomposition import PCA
- from sklearn.cluster import DBSCAN
- from sklearn.model_selection import train_test_split
- from sklearn.metrics import accuracy_score, classification_report, f1_score, precision_score, recall_score, roc_curve, auc, confusion_matrix
- from scipy.cluster.hierarchy import linkage, dendrogram
- from tensorflow.keras.models import Sequential
- from tensorflow.keras.layers import Conv1D, MaxPooling1D, Flatten, Dense, Dropout
- from tensorflow.keras.optimizers import Adam
- from tensorflow.keras.utils import to_categorical
- from imblearn.over_sampling import SMOTE
- # %%
- # Load the dataset
- df = pd.read_csv('/content/drive/MyDrive/Colab Notebooks/preprocessed_features.csv')
- if "Sub_ID" in df.columns:
- df.drop(columns=["Sub_ID"], inplace=True)
- # %%
- # Compute new features
- df["SNR_Difference"] = df["SNR_anat"] - df["SNR_dti"]
- df["FSVI"] = df[["DVARS", "DVARS_func"]].mean(axis=1)
- df["MIS"] = df[["PercentFD_greater_than_0.20", "PercentFD_greater_than_0.20_func"]].sum(axis=1)
- df.fillna(df.median(), inplace=True)
- # Correlation matrix
- numeric_df = df.select_dtypes(include=['number'])
- plt.figure(figsize=(12, 8))
- sns.heatmap(numeric_df.corr(), annot=True, fmt=".2f", cmap="coolwarm", linewidths=0.5)
- plt.title("Correlation Matrix of MRI Features")
- plt.show()
- features = numeric_df.columns.tolist()
- X_features = df[features]
- threshold = df["FSVI"].median()
- df["Refined_Diagnosis"] = np.where(df["FSVI"] > threshold, "ASD-like", "Control-like")
- y_labels = df["Refined_Diagnosis"].map({"Control-like": 0, "ASD-like": 1})
- X_train, X_test, y_train, y_test = train_test_split(X_features, y_labels, test_size=0.2, random_state=42, stratify=y_labels)
- smote = SMOTE(random_state=42)
- X_train_res, y_train_res = smote.fit_resample(X_train, y_train)
- # %%
- # Random Forest
- rf_model = RandomForestClassifier(n_estimators=100, random_state=42)
- rf_model.fit(X_train_res, y_train_res)
- rf_pred = rf_model.predict(X_test)
- print("Random Forest Accuracy:", accuracy_score(y_test, rf_pred))
- print("Random Forest Precision:", precision_score(y_test, rf_pred))
- print("Random Forest Recall:", recall_score(y_test, rf_pred))
- print("Random Forest F1 Score:", f1_score(y_test, rf_pred))
- print("Random Forest Classification Report:\n", classification_report(y_test, rf_pred))
- # Confusion Matrix for Random Forest
- conf_matrix_rf = confusion_matrix(y_test, rf_pred)
- plt.figure(figsize=(6, 4))
- sns.heatmap(conf_matrix_rf, annot=True, fmt='d', cmap='Blues', xticklabels=["Control-like", "ASD-like"], yticklabels=["Control-like", "ASD-like"])
- plt.title('Random Forest Confusion Matrix')
- plt.ylabel('True Label')
- plt.xlabel('Predicted Label')
- plt.show()
- # ROC Curve for Random Forest
- rf_pred_prob = rf_model.predict_proba(X_test)[:, 1]
- fpr_rf, tpr_rf, _ = roc_curve(y_test, rf_pred_prob)
- roc_auc_rf = auc(fpr_rf, tpr_rf)
- plt.figure(figsize=(6, 4))
- plt.plot(fpr_rf, tpr_rf, color='darkorange', lw=2, label='ROC Curve (AUC = {:.2f})'.format(roc_auc_rf))
- plt.plot([0, 1], [0, 1], color='navy', lw=2, linestyle='--')
- plt.title('Random Forest ROC Curve')
- plt.xlabel('False Positive Rate')
- plt.ylabel('True Positive Rate')
- plt.legend(loc="lower right")
- plt.show()
- # %%
- # PCA Visualization
- pca = PCA(n_components=2)
- X_pca = pca.fit_transform(X_features)
- df["PCA1"], df["PCA2"] = X_pca[:, 0], X_pca[:, 1]
- # Hierarchical Clustering
- plt.figure(figsize=(12, 6))
- linkage_matrix = linkage(X_pca, method='ward')
- dendrogram(linkage_matrix, labels=df["Refined_Diagnosis"].values, leaf_rotation=90, leaf_font_size=8)
- plt.title("Hierarchical Clustering Dendrogram")
- plt.xlabel("Subjects")
- plt.ylabel("Distance")
- plt.show()
- # DBSCAN Clustering
- dbscan = DBSCAN(eps=0.5, min_samples=5)
- df["DBSCAN_Cluster"] = dbscan.fit_predict(X_pca)
- plt.figure(figsize=(10, 6))
- sns.scatterplot(x=df["PCA1"], y=df["PCA2"], hue=df["DBSCAN_Cluster"], palette="viridis", alpha=0.7)
- plt.title("DBSCAN Clustering on MRI Data")
- plt.xlabel("Principal Component 1")
- plt.ylabel("Principal Component 2")
- plt.legend(title="Cluster ID")
- plt.show()
- # %%
- # CNN Model
- X_train_cnn_res = X_train_res.values.reshape(X_train_res.shape[0], X_train_res.shape[1], 1)
- X_test_cnn = X_test.values.reshape(X_test.shape[0], X_test.shape[1], 1)
- y_train_cnn_res = to_categorical(y_train_res, num_classes=2)
- y_test_cnn = to_categorical(y_test, num_classes=2)
- cnn_model = Sequential()
- cnn_model.add(Conv1D(filters=64, kernel_size=3, activation='relu', input_shape=(X_train.shape[1], 1)))
- cnn_model.add(MaxPooling1D(pool_size=2))
- cnn_model.add(Conv1D(filters=128, kernel_size=3, activation='relu'))
- cnn_model.add(MaxPooling1D(pool_size=2))
- cnn_model.add(Flatten())
- cnn_model.add(Dense(128, activation='relu'))
- cnn_model.add(Dropout(0.5))
- cnn_model.add(Dense(2, activation='softmax'))
- cnn_model.compile(optimizer=Adam(learning_rate=0.001), loss='categorical_crossentropy', metrics=['accuracy'])
- history = cnn_model.fit(X_train_cnn_res, y_train_cnn_res, epochs=20, batch_size=32, validation_split=0.2, verbose=1)
- # CNN Evaluation
- cnn_pred_prob = cnn_model.predict(X_test_cnn)
- cnn_pred = np.argmax(cnn_pred_prob, axis=1)
- y_test_labels = np.argmax(y_test_cnn, axis=1)
- print("CNN Accuracy:", accuracy_score(y_test_labels, cnn_pred))
- print("CNN Precision:", precision_score(y_test_labels, cnn_pred))
- print("CNN Recall:", recall_score(y_test_labels, cnn_pred))
- print("CNN F1 Score:", f1_score(y_test_labels, cnn_pred))
- print("CNN Classification Report:\n", classification_report(y_test_labels, cnn_pred))
- # Confusion Matrix for CNN
- conf_matrix_cnn = confusion_matrix(y_test_labels, cnn_pred)
- plt.figure(figsize=(6, 4))
- sns.heatmap(conf_matrix_cnn, annot=True, fmt='d', cmap='Blues', xticklabels=["Control-like", "ASD-like"], yticklabels=["Control-like", "ASD-like"])
- plt.title('CNN Confusion Matrix')
- plt.ylabel('True Label')
- plt.xlabel('Predicted Label')
- plt.show()
- # ROC Curve for CNN
- fpr_cnn, tpr_cnn, _ = roc_curve(y_test_labels, cnn_pred_prob[:, 1])
- roc_auc_cnn = auc(fpr_cnn, tpr_cnn)
- plt.figure(figsize=(6, 4))
- plt.plot(fpr_cnn, tpr_cnn, color='darkorange', lw=2, label='ROC Curve (AUC = {:.2f})'.format(roc_auc_cnn))
- plt.plot([0, 1], [0, 1], color='navy', lw=2, linestyle='--')
- plt.title('CNN ROC Curve')
- plt.xlabel('False Positive Rate')
- plt.ylabel('True Positive Rate')
- plt.legend(loc="lower right")
- plt.show()
- # Outlier Analysis
- outliers_df = df[df["DBSCAN_Cluster"] == -1]
- df = df[df["DBSCAN_Cluster"] != -1]
- outlier_stats = outliers_df[features].mean()
- non_outlier_stats = df[features].mean()
- outlier_deviation = ((outlier_stats - non_outlier_stats) / non_outlier_stats) * 100
- print("Top Outlier Deviations:\n", outlier_deviation.sort_values(ascending=False).head(10))
- # %%
- #resnet
- import numpy as np
- import pandas as pd
- import matplotlib.pyplot as plt
- import seaborn as sns
- from sklearn.model_selection import train_test_split
- from sklearn.metrics import accuracy_score, classification_report, f1_score, precision_score, recall_score, roc_curve, auc, confusion_matrix
- from tensorflow.keras.models import Model
- from tensorflow.keras.layers import Input, Conv1D, BatchNormalization, Activation, Add, GlobalAveragePooling1D, Dense
- from tensorflow.keras.utils import to_categorical
- from tensorflow.keras.optimizers import Adam
- from imblearn.over_sampling import SMOTE
- # Load the dataset
- df = pd.read_csv('/content/drive/MyDrive/Colab Notebooks/preprocessed_features.csv')
- # Drop Sub_ID if present
- if "Sub_ID" in df.columns:
- df.drop(columns=["Sub_ID"], inplace=True)
- # Compute new features
- df["SNR_Difference"] = df["SNR_anat"] - df["SNR_dti"]
- df["FSVI"] = df[["DVARS", "DVARS_func"]].mean(axis=1)
- df["MIS"] = df[["PercentFD_greater_than_0.20", "PercentFD_greater_than_0.20_func"]].sum(axis=1)
- # Handle missing values
- df.fillna(df.median(), inplace=True)
- # Define features and target
- numeric_df = df.select_dtypes(include=['number'])
- features = numeric_df.columns.tolist()
- X_features = df[features]
- # Define binary target (ASD-like and Control-like)
- threshold = df["FSVI"].median()
- df["Refined_Diagnosis"] = np.where(df["FSVI"] > threshold, "ASD-like", "Control-like")
- y_labels = df["Refined_Diagnosis"].map({"Control-like": 0, "ASD-like": 1})
- # Train-test split
- X_train, X_test, y_train, y_test = train_test_split(X_features, y_labels, test_size=0.2, random_state=42, stratify=y_labels)
- # Apply SMOTE for class imbalance
- smote = SMOTE(random_state=42)
- X_train_res, y_train_res = smote.fit_resample(X_train, y_train)
- # Reshape data for 1D ResNet (samples, time_steps, features)
- X_train_res = X_train_res.values.reshape(X_train_res.shape[0], X_train_res.shape[1], 1)
- X_test = X_test.values.reshape(X_test.shape[0], X_test.shape[1], 1)
- # One-hot encode labels
- y_train_res_cat = to_categorical(y_train_res, num_classes=2)
- y_test_cat = to_categorical(y_test, num_classes=2)
- # Define a simple 1D ResNet block
- def resnet_block(input_layer, filters, kernel_size=3):
- x = Conv1D(filters, kernel_size, padding="same")(input_layer)
- x = BatchNormalization()(x)
- x = Activation("relu")(x)
- x = Conv1D(filters, kernel_size, padding="same")(x)
- x = BatchNormalization()(x)
- # Skip connection
- shortcut = Conv1D(filters, 1, padding="same")(input_layer)
- x = Add()([x, shortcut])
- x = Activation("relu")(x)
- return x
- # Build the 1D ResNet model
- input_layer = Input(shape=(X_train_res.shape[1], 1))
- x = resnet_block(input_layer, 64)
- x = resnet_block(x, 128)
- x = resnet_block(x, 256)
- x = GlobalAveragePooling1D()(x)
- x = Dense(128, activation="relu")(x)
- x = Dense(2, activation="softmax")(x)
- resnet_model = Model(inputs=input_layer, outputs=x)
- # Compile the model
- resnet_model.compile(optimizer=Adam(learning_rate=0.001), loss='categorical_crossentropy', metrics=['accuracy'])
- # Train the model
- history = resnet_model.fit(X_train_res, y_train_res_cat, epochs=30, batch_size=32, validation_split=0.2, verbose=1)
- # Predict on test set
- y_pred_prob = resnet_model.predict(X_test)
- y_pred = np.argmax(y_pred_prob, axis=1)
- # Evaluate performance
- print("ResNet Accuracy:", accuracy_score(y_test, y_pred))
- print("ResNet Precision:", precision_score(y_test, y_pred))
- print("ResNet Recall:", recall_score(y_test, y_pred))
- print("ResNet F1 Score:", f1_score(y_test, y_pred))
- print("ResNet Classification Report:\n", classification_report(y_test, y_pred))
- # Plot confusion matrix
- conf_matrix = confusion_matrix(y_test, y_pred)
- plt.figure(figsize=(6, 4))
- sns.heatmap(conf_matrix, annot=True, fmt='d', cmap='Blues', xticklabels=["Control-like", "ASD-like"], yticklabels=["Control-like", "ASD-like"])
- plt.title('ResNet Confusion Matrix')
- plt.ylabel('True Label')
- plt.xlabel('Predicted Label')
- plt.show()
- # ROC Curve
- fpr, tpr, _ = roc_curve(y_test, y_pred_prob[:, 1])
- roc_auc = auc(fpr, tpr)
- plt.figure(figsize=(6, 4))
- plt.plot(fpr, tpr, color='darkorange', lw=2, label='ROC Curve (AUC = {:.2f})'.format(roc_auc))
- plt.plot([0, 1], [0, 1], color='navy', lw=2, linestyle='--')
- plt.xlabel('False Positive Rate')
- plt.ylabel('True Positive Rate')
- plt.title('ResNet ROC Curve')
- plt.legend(loc="lower right")
- plt.show()
- # %%
- import numpy as np
- import pandas as pd
- import matplotlib.pyplot as plt
- import seaborn as sns
- from sklearn.ensemble import RandomForestClassifier
- from sklearn.decomposition import PCA
- from sklearn.cluster import DBSCAN
- from sklearn.svm import SVC
- from sklearn.neighbors import KNeighborsClassifier
- from xgboost import XGBClassifier
- from sklearn.model_selection import train_test_split, GridSearchCV
- from sklearn.metrics import accuracy_score, classification_report, f1_score, precision_score, recall_score, roc_curve, auc, confusion_matrix
- from scipy.cluster.hierarchy import linkage, dendrogram
- # Load the dataset
- df = pd.read_csv('/content/drive/MyDrive/Colab Notebooks/preprocessed_features.csv')
- # Ensure Sub_ID is removed if necessary
- if "Sub_ID" in df.columns:
- df.drop(columns=["Sub_ID"], inplace=True)
- # Compute new features
- df["SNR_Difference"] = df["SNR_anat"] - df["SNR_dti"]
- df["FSVI"] = df[["DVARS", "DVARS_func"]].mean(axis=1)
- df["MIS"] = df[["PercentFD_greater_than_0.20", "PercentFD_greater_than_0.20_func"]].sum(axis=1)
- # Handle missing values
- df.fillna(df.median(), inplace=True)
- # Define features for model training
- numeric_df = df.select_dtypes(include=['number'])
- features = numeric_df.columns.tolist()
- X_features = df[features]
- # Define target labels
- threshold = df["FSVI"].median()
- df["Refined_Diagnosis"] = np.where(df["FSVI"] > threshold, "ASD-like", "Control-like")
- y_labels = df["Refined_Diagnosis"].map({"Control-like": 0, "ASD-like": 1})
- # Train-test split
- X_train, X_test, y_train, y_test = train_test_split(X_features, y_labels, test_size=0.2, random_state=42)
- # Train models
- rf = RandomForestClassifier(n_estimators=100, max_depth=10, min_samples_split=5, random_state=42)
- rf.fit(X_train, y_train)
- param_grid = {'C': [0.1, 1, 10], 'gamma': ['scale', 'auto', 0.01, 0.1, 1], 'kernel': ['rbf']}
- grid_search = GridSearchCV(SVC(probability=True), param_grid, cv=5, scoring='accuracy')
- grid_search.fit(X_train, y_train)
- svm_model = grid_search.best_estimator_
- knn_model = KNeighborsClassifier(n_neighbors=5)
- knn_model.fit(X_train, y_train)
- xgb_model = XGBClassifier(use_label_encoder=False, eval_metric='logloss')
- xgb_model.fit(X_train, y_train)
- # Predictions
- svm_pred, knn_pred, xgb_pred = svm_model.predict(X_test), knn_model.predict(X_test), xgb_model.predict(X_test)
- svm_probs = svm_model.predict_proba(X_test)[:, 1]
- knn_probs = knn_model.predict_proba(X_test)[:, 1]
- xgb_probs = xgb_model.predict_proba(X_test)[:, 1]
- # Compute evaluation metrics
- def evaluate_model(name, y_test, y_pred):
- print(f"{name} Accuracy:", accuracy_score(y_test, y_pred))
- print(f"{name} Precision:", precision_score(y_test, y_pred))
- print(f"{name} Recall:", recall_score(y_test, y_pred))
- print(f"{name} F1 Score:", f1_score(y_test, y_pred))
- print(f"{name} Classification Report:\n", classification_report(y_test, y_pred))
- evaluate_model("SVM", y_test, svm_pred)
- evaluate_model("KNN", y_test, knn_pred)
- evaluate_model("XGBoost", y_test, xgb_pred)
- # AUC-ROC Plots
- fpr_svm, tpr_svm, _ = roc_curve(y_test, svm_probs)
- roc_auc_svm = auc(fpr_svm, tpr_svm)
- fpr_knn, tpr_knn, _ = roc_curve(y_test, knn_probs)
- roc_auc_knn = auc(fpr_knn, tpr_knn)
- fpr_xgb, tpr_xgb, _ = roc_curve(y_test, xgb_probs)
- roc_auc_xgb = auc(fpr_xgb, tpr_xgb)
- plt.figure(figsize=(10, 6))
- plt.plot(fpr_svm, tpr_svm, color='blue', label=f'SVM (AUC = {roc_auc_svm:.2f})')
- plt.plot(fpr_knn, tpr_knn, color='red', label=f'KNN (AUC = {roc_auc_knn:.2f})')
- plt.plot(fpr_xgb, tpr_xgb, color='green', label=f'XGBoost (AUC = {roc_auc_xgb:.2f})')
- plt.plot([0, 1], [0, 1], color='gray', linestyle='--')
- plt.xlabel("False Positive Rate")
- plt.ylabel("True Positive Rate")
- plt.title("ROC Curve")
- plt.legend()
- plt.show()
- # Confusion Matrices
- plt.figure(figsize=(18, 5))
- plt.subplot(1, 3, 1)
- sns.heatmap(confusion_matrix(y_test, svm_pred), annot=True, fmt='d', cmap='Blues')
- plt.title("SVM Confusion Matrix")
- plt.xlabel("Predicted")
- plt.ylabel("Actual")
- plt.subplot(1, 3, 2)
- sns.heatmap(confusion_matrix(y_test, knn_pred), annot=True, fmt='d', cmap='Reds')
- plt.title("KNN Confusion Matrix")
- plt.xlabel("Predicted")
- plt.ylabel("Actual")
- plt.subplot(1, 3, 3)
- sns.heatmap(confusion_matrix(y_test, xgb_pred), annot=True, fmt='d', cmap='Greens')
- plt.title("XGBoost Confusion Matrix")
- plt.xlabel("Predicted")
- plt.ylabel("Actual")
- plt.show()
- # %%
- #ENSEMBLE - MAJORITY
- import numpy as np
- import pandas as pd
- import matplotlib.pyplot as plt
- import seaborn as sns
- from sklearn.decomposition import PCA
- from sklearn.cluster import DBSCAN
- from sklearn.svm import SVC
- from sklearn.neighbors import KNeighborsClassifier
- from xgboost import XGBClassifier
- from sklearn.model_selection import train_test_split, GridSearchCV
- from sklearn.metrics import accuracy_score, classification_report, f1_score, precision_score, recall_score, roc_curve, auc, confusion_matrix
- from scipy.cluster.hierarchy import linkage, dendrogram
- # Load the dataset
- df = pd.read_csv('/content/drive/MyDrive/Colab Notebooks/preprocessed_features.csv')
- # Ensure Sub_ID is removed if necessary
- if "Sub_ID" in df.columns:
- df.drop(columns=["Sub_ID"], inplace=True)
- # Compute new features
- df["SNR_Difference"] = df["SNR_anat"] - df["SNR_dti"]
- df["FSVI"] = df[["DVARS", "DVARS_func"]].mean(axis=1)
- df["MIS"] = df[["PercentFD_greater_than_0.20", "PercentFD_greater_than_0.20_func"]].sum(axis=1)
- # Handle missing values
- df.fillna(df.median(), inplace=True)
- # Define features for model training
- numeric_df = df.select_dtypes(include=['number'])
- features = numeric_df.columns.tolist()
- X_features = df[features]
- # Define target labels
- threshold = df["FSVI"].median()
- df["Refined_Diagnosis"] = np.where(df["FSVI"] > threshold, "ASD-like", "Control-like")
- y_labels = df["Refined_Diagnosis"].map({"Control-like": 0, "ASD-like": 1})
- # Train-test split
- X_train, X_test, y_train, y_test = train_test_split(X_features, y_labels, test_size=0.2, random_state=42)
- # Apply DBSCAN for outlier detection
- dbscan = DBSCAN(eps=0.5, min_samples=5)
- df['DBSCAN_Cluster'] = dbscan.fit_predict(X_features)
- # Identify outliers (DBSCAN assigns label -1 to outliers)
- outliers_df = df[df["DBSCAN_Cluster"] == -1]
- non_outliers_df = df[df["DBSCAN_Cluster"] != -1]
- # Visualize outliers
- plt.figure(figsize=(10, 6))
- sns.scatterplot(x=non_outliers_df['FSVI'], y=non_outliers_df['DVARS'], color='blue', label='Non-Outliers')
- sns.scatterplot(x=outliers_df['FSVI'], y=outliers_df['DVARS'], color='red', label='Outliers')
- plt.xlabel("FSVI")
- plt.ylabel("DVARS")
- plt.title("Outlier Detection using DBSCAN")
- plt.legend()
- plt.show()
- # Optionally, remove outliers
- df_cleaned = non_outliers_df.drop(columns=['DBSCAN_Cluster'])
- # Define features for model training again (after removing outliers if necessary)
- X_features_cleaned = df_cleaned[features]
- # Re-split the cleaned data
- X_train_cleaned, X_test_cleaned, y_train_cleaned, y_test_cleaned = train_test_split(X_features_cleaned, y_labels.loc[df_cleaned.index], test_size=0.2, random_state=42)
- # Train models
- param_grid = {'C': [0.1, 1, 10], 'gamma': ['scale', 'auto', 0.01, 0.1, 1], 'kernel': ['rbf']}
- grid_search = GridSearchCV(SVC(probability=True), param_grid, cv=5, scoring='accuracy')
- grid_search.fit(X_train_cleaned, y_train_cleaned)
- svm_model = grid_search.best_estimator_
- knn_model = KNeighborsClassifier(n_neighbors=5)
- knn_model.fit(X_train_cleaned, y_train_cleaned)
- xgb_model = XGBClassifier(use_label_encoder=False, eval_metric='logloss')
- xgb_model.fit(X_train_cleaned, y_train_cleaned)
- # Predictions
- svm_pred, knn_pred, xgb_pred = svm_model.predict(X_test_cleaned), knn_model.predict(X_test_cleaned), xgb_model.predict(X_test_cleaned)
- svm_probs = svm_model.predict_proba(X_test_cleaned)[:, 1]
- knn_probs = knn_model.predict_proba(X_test_cleaned)[:, 1]
- xgb_probs = xgb_model.predict_proba(X_test_cleaned)[:, 1]
- # Compute overall evaluation metrics
- def evaluate_models(y_test, preds):
- overall_accuracy = np.mean([accuracy_score(y_test, pred) for pred in preds])
- overall_precision = np.mean([precision_score(y_test, pred) for pred in preds])
- overall_recall = np.mean([recall_score(y_test, pred) for pred in preds])
- overall_f1 = np.mean([f1_score(y_test, pred) for pred in preds])
- print("Overall Model Evaluation:")
- print(f"Accuracy: {overall_accuracy:.4f}")
- print(f"Precision: {overall_precision:.4f}")
- print(f"Recall: {overall_recall:.4f}")
- print(f"F1 Score: {overall_f1:.4f}")
- evaluate_models(y_test_cleaned, [svm_pred, knn_pred, xgb_pred])
- # AUC-ROC Curve
- fpr_svm, tpr_svm, _ = roc_curve(y_test_cleaned, svm_probs)
- fpr_knn, tpr_knn, _ = roc_curve(y_test_cleaned, knn_probs)
- fpr_xgb, tpr_xgb, _ = roc_curve(y_test_cleaned, xgb_probs)
- plt.figure(figsize=(10, 6))
- plt.plot(fpr_svm, tpr_svm, color='blue', label=f'SVM (AUC = {auc(fpr_svm, tpr_svm):.2f})')
- plt.plot(fpr_knn, tpr_knn, color='red', label=f'KNN (AUC = {auc(fpr_knn, tpr_knn):.2f})')
- plt.plot(fpr_xgb, tpr_xgb, color='green', label=f'XGBoost (AUC = {auc(fpr_xgb, tpr_xgb):.2f})')
- plt.plot([0, 1], [0, 1], color='gray', linestyle='--')
- plt.xlabel("False Positive Rate")
- plt.ylabel("True Positive Rate")
- plt.title("ROC Curve")
- plt.legend()
- plt.show()
- # Confusion Matrix for Combined Model Predictions
- final_preds = (svm_pred + knn_pred + xgb_pred) >= 2 # Majority Voting
- conf_matrix = confusion_matrix(y_test_cleaned, final_preds)
- plt.figure(figsize=(6, 6))
- sns.heatmap(conf_matrix, annot=True, fmt='d', cmap='Blues')
- plt.title("Overall Confusion Matrix")
- plt.xlabel("Predicted")
- plt.ylabel("Actual")
- plt.show()
- # Correlation Heatmap
- plt.figure(figsize=(12, 8))
- correlation_matrix = df_cleaned.corr(numeric_only=True)
- sns.heatmap(correlation_matrix, annot=True, fmt=".2f", cmap='coolwarm', linewidths=0.5)
- plt.title("Correlation Matrix - Cleaned Data")
- plt.show()
- # PCA Visualization
- pca = PCA(n_components=2)
- X_pca = pca.fit_transform(X_features_cleaned)
- plt.figure(figsize=(10, 6))
- scatter = plt.scatter(X_pca[:, 0], X_pca[:, 1], c=y_labels.loc[df_cleaned.index], cmap='viridis', edgecolor='k', alpha=0.8)
- plt.colorbar(scatter, label="Diagnosis (0 = Control, 1 = ASD-like)")
- plt.xlabel("Principal Component 1")
- plt.ylabel("Principal Component 2")
- plt.title("PCA Visualization of Data")
- plt.show()
- # Hierarchical Clustering Dendrogram
- plt.figure(figsize=(12, 6))
- linkage_matrix = linkage(X_features_cleaned, method='ward')
- dendrogram(linkage_matrix, leaf_rotation=90, leaf_font_size=8)
- plt.title("Hierarchical Clustering Dendrogram")
- plt.xlabel("Sample Index")
- plt.ylabel("Distance")
- plt.show()
- # %%
- import pandas as pd
- import numpy as np
- from sklearn.model_selection import StratifiedKFold, cross_validate
- from sklearn.svm import SVC
- from sklearn.neighbors import KNeighborsClassifier
- from xgboost import XGBClassifier
- from sklearn.ensemble import VotingClassifier
- from sklearn.cluster import DBSCAN
- from sklearn.metrics import make_scorer, accuracy_score, precision_score, recall_score, f1_score
- # 1. Load the Dataset
- # Replace 'preprocessed_features.csv' with your actual file path
- df = pd.read_csv('/content/drive/MyDrive/Colab Notebooks/preprocessed_features.csv')
- # 2. Preprocessing & Feature Engineering
- if "Sub_ID" in df.columns:
- df.drop(columns=["Sub_ID"], inplace=True)
- # Create engineered metrics
- df["SNR_Difference"] = df["SNR_anat"] - df["SNR_dti"]
- df["FSVI"] = df[["DVARS", "DVARS_func"]].mean(axis=1)
- df["MIS"] = df[["PercentFD_greater_than_0.20", "PercentFD_greater_than_0.20_func"]].sum(axis=1)
- # Handle missing values
- df.fillna(df.median(numeric_only=True), inplace=True)
- # Select numeric features for the model
- numeric_df = df.select_dtypes(include=['number'])
- features = numeric_df.columns.tolist()
- X_all = df[features]
- # Define Target (Using the FSVI median threshold proxy)
- threshold = df["FSVI"].median()
- df["Target"] = np.where(df["FSVI"] > threshold, 1, 0)
- y_all = df["Target"]
- # 3. Outlier Removal (DBSCAN)
- dbscan = DBSCAN(eps=0.5, min_samples=5)
- df['DBSCAN_Cluster'] = dbscan.fit_predict(X_all)
- df_cleaned = df[df["DBSCAN_Cluster"] != -1].copy()
- X = df_cleaned[features]
- y = y_all.loc[df_cleaned.index]
- # 4. Define the Ensemble Models
- # Parameters aligned with the optimal settings found in your notebook
- svm_clf = SVC(C=10, kernel='rbf', gamma='scale', probability=True, random_state=42)
- knn_clf = KNeighborsClassifier(n_neighbors=5)
- xgb_clf = XGBClassifier(
- n_estimators=100,
- learning_rate=0.1,
- max_depth=3,
- use_label_encoder=False,
- eval_metric='logloss',
- random_state=42
- )
- # Create the Majority Voting Ensemble
- voting_clf = VotingClassifier(
- estimators=[('svm', svm_clf), ('knn', knn_clf), ('xgb', xgb_clf)],
- voting='hard'
- )
- # 5. Stratified 10-Fold Cross-Validation Setup
- skf = StratifiedKFold(n_splits=10, shuffle=True, random_state=42)
- # Define metrics to track
- scoring = ['accuracy', 'precision', 'recall', 'f1']
- # Run Cross-Validation
- print("Running Stratified 10-Fold Cross-Validation...")
- cv_results = cross_validate(voting_clf, X, y, cv=skf, scoring=scoring)
- # Calculate AUC separately using a Soft Voting version (required for probability-based metrics)
- voting_clf_soft = VotingClassifier(
- estimators=[('svm', svm_clf), ('knn', knn_clf), ('xgb', xgb_clf)],
- voting='soft'
- )
- cv_auc = cross_validate(voting_clf_soft, X, y, cv=skf, scoring='roc_auc')
- # 6. Output Final Results for the Paper
- print("\n--- Final Model Performance (Mean ± SD) ---")
- print(f"Accuracy: {np.mean(cv_results['test_accuracy'])*100:.2f}% (±{np.std(cv_results['test_accuracy'])*100:.2f}%)")
- print(f"Precision: {np.mean(cv_results['test_precision'])*100:.2f}% (±{np.std(cv_results['test_precision'])*100:.2f}%)")
- print(f"Recall: {np.mean(cv_results['test_recall'])*100:.2f}% (±{np.std(cv_results['test_recall'])*100:.2f}%)")
- print(f"F1-Score: {np.mean(cv_results['test_f1'])*100:.2f}% (±{np.std(cv_results['test_f1'])*100:.2f}%)")
- print(f"ROC AUC: {np.mean(cv_auc['test_score']):.4f} (±{np.std(cv_auc['test_score']):.4f})")
Cross_validation_Sun_MRI .ipynb at commit 54dc118, under MIT · at the source
Overview
- Department of Electrical Engineering, National Institute of Technology Manipur (NITM), Manipur, India
- Department of Electrical and Electronics Engineering, Christ College of Engineering, Thrissur, Kerala 680125 India
- Department of Electronics and Communication Engineering, Christ College of Engineering, Thrissur, Kerala 680125 India
- Department of Computer Science and Engineering, Christ College of Engineering, Thrissur, Kerala 680125 India
- Department of Electronics and Communication Engineering, National Institute of Technology Manipur (NITM), Manipur, India
- Department of Zoology, Christ College (Autonomous), 680125 Irinjalakuda, India
- Department of Electronics and Communication, Indian Institute of Technology Roorkee (IITR), Roorkee, India
Abstract
The abstract is not reproduced here: the paper's license (CC BY-NC-ND) does not allow it. Read it in the paper, at the publisher or on Europe PMC.
Repositories
Its files are read in the Code ↔ Paper reader above, with 11 matches between paragraphs and lines of code.
Zenodo 20196663
Availability: 1 check, the latest on 28 September 2026: the link answers (HTTP 200)
- 28 September 2026: the link answers (HTTP 200)
4 files
- datasets/
preprocessed_datasets/ , Python, 200 linespreprocessed_pipeline.py - notebooks/
Cross_validation_Sun_MRI , Jupyter, 679 lines.ipynb - notebooks/
Suni_Final_MRI.ipynb , Jupyter, 1,391 lines - README.md, Text, 2 lines
Suni-Jose/Autism-detection-using-MRI
54dc118e83fcc35ac87cb578020720a448c48a2c, 15 May 2026Availability: 1 check, the latest on 28 September 2026: the link answers
- 28 September 2026: the link answers
5 files
- datasets/
preprocessed_datasets/ , Python, 200 lines, 2 matchespreprocessed_pipeline.py - notebooks/
Cross_validation_Sun_MRI , Jupyter, 679 lines, 5 matches.ipynb - notebooks/
Suni_Final_MRI.ipynb , Jupyter, 1,391 lines, 4 matches - LICENSE, License, 21 lines
- README.md, Text, 2 lines
Code availability statement
The paper has a code availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:
- it points to the authors' code: Suni-Jose/
Autism-detection-using-M , Zenodo 20196663RI
Read it in the paper: doi.org/10.1038/s41598-026-55163-y.
Tracing map
Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.
What the map holds:
- 2 repositories of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
- 6 scripts, each with its path and the digest of its content;
- 11 matches between paragraphs of the paper and lines of the code (method lexical-v1);
- neither the text of the paper nor the code itself.
Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.
Data
Datasets cited
- github.com/
sanmaryjoseph/ , at github.com; found in the Zenodo archive recordautism-detection-using-m ri
Data availability statement
The paper has a data availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:
- no repository, dataset or request procedure was recognized in it
Read it in the paper: doi.org/10.1038/s41598-026-55163-y.
Versions
The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.
Version 1, 28 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 7 authors, 9 keywords, 7 MeSH terms, 9 references.
Cite
This paper
V, M. P., Babu, C., Jose, S., Adhikari, S., Singh, L. S., Francis, J., & Parekkattil, A. V. (2026). Autism spectrum disorder identification using machine learning models on MRI data. Scientific reports, 16(1), 24650. https://
BibTeX
@article{v2026autism,
author = {V, Milner Paul and Babu, Caren and Jose, Suni and Adhikari, Shuma and Singh, Loitongbam Surajkumar and Francis, Jijo and Parekkattil, Adarsh V},
title = {{Autism spectrum disorder identification using machine learning models on MRI data}},
journal = {Scientific reports},
year = {2026},
month = may,
volume = {16},
number = {1},
pages = {24650},
publisher = {Nature Publishing Group},
issn = {2045-2322},
doi = {10.1038/
url = {https://
pmid = {42215668},
pmcid = {PMC13454262}
}
RIS
TY - JOUR
AU - V, Milner Paul
AU - Babu, Caren
AU - Jose, Suni
AU - Adhikari, Shuma
AU - Singh, Loitongbam Surajkumar
AU - Francis, Jijo
AU - Parekkattil, Adarsh V
TI - Autism spectrum disorder identification using machine learning models on MRI data
T2 - Scientific reports
J2 - Sci Rep
PY - 2026
DA - 2026/
VL - 16
IS - 1
SP - 24650
SN - 2045-2322
PB - Nature Publishing Group
DO - 10.1038/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1038/
"type": "article-journal",
"title": "Autism spectrum disorder identification using machine learning models on MRI data",
"container-title": "Scientific reports",
"author": [
{
"family": "V",
"given": "Milner Paul"
},
{
"family": "Babu",
"given": "Caren"
},
{
"family": "Jose",
"given": "Suni"
},
{
"family": "Adhikari",
"given": "Shuma"
},
{
"family": "Singh",
"given": "Loitongbam Surajkumar"
},
{
"family": "Francis",
"given": "Jijo"
},
{
"family": "Parekkattil",
"given": "Adarsh V"
}
],
"container-title-short":
"volume": "16",
"issue": "1",
"page": "24650",
"DOI": "10.1038/
"PMID": "42215668",
"PMCID": "PMC13454262",
"ISSN": "2045-2322",
"publisher": "Nature Publishing Group",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
5,
29
]
]
}
}
The tracing map gets a citation of its own once an author has validated it and it has a DOI.
Similar papers
The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.
- [1] doi:10.1038/s42003-026-10957-8 [code]
- Brain defence by the extracellular matrix protein Cochlin.Journal: Communications biologyIn common: imbalanced-learn, XGBoost, Keras, 7 other tools
- [2] doi:10.3390/s26175327 [code]
- Subject Identity Confounds qEEG Emotion Recognition on DEAP and DREAMER.Journal: Sensors (Basel, Switzerland)In common: imbalanced-learn, XGBoost, Keras, 7 other tools
- [3] doi:10.1038/s41398-026-04081-8 [code]
- Functional system-specific brain aging across the Alzheimer's disease continuum.Journal: Translational psychiatryIn common: imbalanced-learn, Keras, TensorFlow, 6 other tools, structural MRI / diffusion, clinical / translational
- [4] doi:10.7554/elife.110588 [code]
- Opening the black box toward a modular approach to spike sorting.Journal: eLifeIn common: imbalanced-learn, XGBoost, TensorFlow, 6 other tools
- [5] doi:10.1371/journal.pcbi.1014615 [code]
- Toward reliable machine learning models for neural circuit inference: A diagnostic study of CNNs on spike trains.Journal: PLoS computational biologyIn common: XGBoost, Keras, TensorFlow, 6 other tools
- [6] doi:10.1038/s41598-026-64405-y [code]
- Evaluating clinical and neuroimaging predictors for cognitive-behavioral therapy outcome in obsessive-compulsive disorder.Journal: Scientific reportsIn common: imbalanced-learn, XGBoost, seaborn, 5 other tools, structural MRI / diffusion, clinical / translational
- [7] doi:10.1371/journal.pgen.1012242 [code]
- Wiz regulates clustered protocadherin genes by restricting CTCF/
cohesin loop extrusion in a genomic-distance biased manner. Journal: PLoS geneticsIn common: XGBoost, Keras, TensorFlow, 6 other tools - [8] doi:10.3389/fpsyg.2026.1774068 [code]
- Analysis of cognitive mechanisms in phoneme perception and pronunciation errors among Korean language learners.Journal: Frontiers in psychologyIn common: XGBoost, Keras, TensorFlow, 6 other tools
- [9] doi:10.1038/s41598-026-48613-0 [code]
- An snRNA-seq aging clock for the fruit fly head sheds light on sex-biased aging.Journal: Scientific reportsIn common: XGBoost, Keras, TensorFlow, 6 other tools
- [10] doi:10.1016/j.nicl.2026.104012 [code]
- Structural-functional multilayer brain network properties and outcome of combined repetitive transcranial magnetic stimulation and psychotherapy for obsessive-compulsive disorder.Journal: NeuroImage. ClinicalIn common: imbalanced-learn, XGBoost, seaborn, 5 other tools, structural MRI / diffusion
Contribute
The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.
Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.
Claim this paper
Correct its record
Say what each link of this record is, remove the ones that are not the paper's, add the ones that are missing. The correction becomes a new version of the record, in its Versions section.
Validate its tracing map
You validate the map as this page shows it: 2 repositories of the authors' code, each at its verified commit and with its license, 6 scripts, and 11 matches between paragraphs and code (see the Code and Map sections). It then receives a DOI on Zenodo, with you (your ORCID iD) and OSCR as its creators; the code itself is not deposited.
The map's fingerprint: sha256:35be0c190386e862…
Add the badge to its README
The badge links the code to this page. Copy one of these into the README of the paper's code: only you decide where it goes, and nothing is changed for you.
Markdown
[, paste the snippet at the top, then “Commit changes…” and, to review it first, “Create a new branch and start a pull request”. You open the pull request; OSCR asks for no permission.
Request its removal
To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).
Discussion, reproductions, activity
Discussion: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.
Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.
Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.
