This is a code implementation of the UFA-Net method proposed in the manuscript "Unsupervised Cross-Domain Functional MRI Adaptation for Automated Major Depressive Disorder Identification".
torch==1.10.0
torchvision==0.2.1
numpy==1.21.2
scikit_learn==1.1.3
We construct a demo consisting of 10 source examples and 10 target examples.
Run: synthesize_data.py
The shape of the constructed data and label:
src_data.npy
(SrcNum, 1, T, NodeNum, 1)
src_lbl.npy(SrcNum, )
tgt_data.npy(TgtNum, 1, T, NodeNum, 1)
tgt_lbl.npy(TgtNum, )
adj_matrix.npy(NodeNum, NodeNum)
where
SrcNum
is the number of subjects in the source domain
TgtNum
is the number of subjects in the target domain
T
is the number of time points of a fMRI scan (here is 200)
NodeNum
is the number of brain nodes/ROIs (here is 116, corresponding to AAL116 atlas)
This is a two-step optimization method.
In folder codes
, Run: python main_pretrain.py
The pretrained model is saved in: checkpoints_pretrain
In folder codes
, Run: python main_UDA.py
The classification results are saved in: checkpoints
-
Code package installation:
pip install UFANET
-
Pretrained model optimization on labeled source domain:
from UFA.main_pretrain import main_pretrain
main_pretrain(ROOT_PATH='/data/path/directory/', SAVE_PATH='/pretrain_result/path/directory/')
whereROOT_PATH
is the data directory, andSAVE_PATH
is the directory saving the pretrained checkpoints. -
Adaptation model optimization on labeled source domain and unlabeled target domain:
from UFA.main_UDA import main_UDA
main_UDA(ROOT_PATH='/data/path/directory/', LOAD_PATH='/pretrain_result/path/directory/', SAVE_PATH='/final_result/path/directory/')
whereLOAD_PATH
is the directory for checkpoints saved in the pretrained stage, andSAVE_PATH
is the directory for final test results.