ADNI多模态神经影像整理笔记

目标:将ADNI下载的多模态格式影像转为BIDS存储格式的NIFTI文件
环境:Ubuntu 2020
工具包:

1. 下载影像

官网:https://ida.loni.usc.edu/login.jsp
注册账号,Proposal通过之后就可以下载了。
在IDA里面找到待下载的影像,打包下载。
推荐分数个压缩包下载,方便后续解压。
推荐使用advance research

IDA普通搜索界面,找到待下载的影像,打包下载
文件下载界面

ADNI image acquisition (https://adni.loni.usc.edu/methods/mri-tool/mri-acquisition/)

2. 解压影像

用Ubuntu自带的解压工具即可解压。
由于传输故障可能出现无法解压的情况。下载完之后要及时查看,以便及时重下。

10个DTI压缩包
解压

典型文件结构

3. 汇总影像到一个目录下

以下步骤适用于dicom或者nifti格式
首先利用mv指令将所有包下的sub级别的目录移动到一起(如都移动到/adni/dicom/dti/)。

mv alldti2/ADNI/* ~/adni/dicom/dti/

由于分批下载的特性,不同子包之间可能出现1️⃣重复下载 2️⃣同个被试的多次扫描出现在不同包里。
这两种情况均会导致mv失败。因此需要使用rsync进行一次同步。

rsync -av --ignore-existing alldti2/ADNI/* ~/adni/dicom/dti/

为节省空间,同步结束之后可以只保留/adni/dicom/dti/,删除子包以及解压的子包。

汇总之后的文件夹,有的被试下面可能有多个扫描
Single Scan

4. 获得下载汇总表

汇总到一个文件夹后需要对下载情况进行评估。
目的主要是1️⃣找到异常影像(文件大小异常、volume数目异常等等)2️⃣ 统计跨模态的id

4.1汇总nifti格式的下载情况

*需要tidyverse包和glue包

# Returns a summary table of downloaded nifti files of a single modality
# Usage: summary_nifti(path). The path has "011_S_0003" "011_S_0005" "011_S_0005" "011_S_0005" ...
# "id_subject"        "image_path"        "image_size"        "image_description" "image_date"        "image_time"        "image_ID" 
summary_nifti <- function(path.download){
  future::plan(future::multisession, workers = 8)
  result <- furrr::future_map_dfr(list.files(path.download), function(id_subject) {
    map_dfr(list.files(glue('{path.download}/{id_subject}')), function(image_description){
      map_dfr(list.files(glue('{path.download}/{id_subject}/{image_description}')), function(image_time){
        map_dfr(
          list.files(glue('{path.download}/{id_subject}/{image_description}/{image_time}')),
          function(image_ID){
            filename <- list.files(glue('{path.download}/{id_subject}/{image_description}/{image_time}/{image_ID}'))
            filepath <- glue('{path.download}/{id_subject}/{image_description}/{image_time}/{image_ID}/{filename}')
            file_size = file.info(filepath)$size / 1000^2
            return(
              tibble(
                id_subject = id_subject,
                image_path = filepath,
                image_size = file_size,
                image_description = image_description,
                image_time = image_time,
                image_ID = image_ID
              )
            )
          })
      })
    })
  })
  result.date <- result %>% separate(col = 'image_time', into = c('image_date', 'image_time'), sep = '_', extra = 'merge')
  return(result.date)
}
汇总表格

4.2 汇总dicom格式下载情况

# Returns a summary table of downloaded nifti files of a single modality
# Usage: summary_nifti(path). The path has "011_S_0003" "011_S_0005" "011_S_0005" "011_S_0005" ...
# "id_subject"        "image_path"        "image_volume_size"        "image_description" "image_date"        "image_time"        "image_ID" 
summary_dicom <- function(path.download){
  future::plan(future::multisession, workers = 3)
  result <- furrr::future_map_dfr(list.files(path.download), function(id_subject) {
    map_dfr(list.files(glue('{path.download}/{id_subject}')), function(image_description){
      map_dfr(list.files(glue('{path.download}/{id_subject}/{image_description}')), function(image_time){
        map_dfr(
          list.files(glue('{path.download}/{id_subject}/{image_description}/{image_time}')),
          function(image_ID){
            dicom_path <- list.files(glue('{path.download}/{id_subject}/{image_description}/{image_time}/{image_ID}'))
            return(
              tibble(
                id_subject = id_subject,
                dicom_volume = length(list.files(dicom_path)),
                dicom_path = dicom_path,
                image_description = image_description,
                image_time = image_time,
                image_ID = image_ID
              )
            )
          })
      })
    })
  })
  result.date <- result %>% separate(col = 'image_time', into = c('image_date', 'image_time'), sep = '_', extra = 'merge')
  return(result.date)
}

5. DICOM转换为BIDS存储格式的NIFTI文件

版权声明:
作者:cc
链接:https://www.techfm.club/p/89898.html
来源:TechFM
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>