-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjoining-data-files.Rmd
73 lines (59 loc) · 2.31 KB
/
joining-data-files.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
---
title: "Joining data files"
date: "Last updated: `r format(Sys.time(), '%B %d, %Y')`"
output: html_document
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r, child = "js/back-to-top.js"}
```
```{css, echo = FALSE}
body .main-container {
max-width: 900px;
}
```
<br>
```{octave, eval = FALSE}
% Example script for batch-processing multiple subjects' Siemens IMA data
% with accompanying water references. Each subject has four scans each to
% be joined together and treated as single datasets during data processing.
%
% Remember to check GannetPreInitialise.m has the appropriate settings for
% your data: 'join' must be set to '1'.
data_dir = '/Users/username/Documents/my_project/data'; % Root data directory
% For joining the four files per subject and batching over multiple
% subjects, the data must be entered an an M x N cell array, where M is the
% number of files per subject and N is the number of subjects. In this
% example, we have only two subjects, each with four files that are to be
% joined.
sub01 = {'sub-01-1/MPRESS1_1.IMA', ...
'sub-01-2/MPRESS2_1.IMA', ...
'sub-01-3/MPRESS3_1.IMA', ...
'sub-01-4/MPRESS4_1.IMA'};
sub02 = {'sub-02-1/MPRESS1_1.IMA', ...
'sub-02-2/MPRESS2_1.IMA', ...
'sub-02-3/MPRESS3_1.IMA', ...
'sub-02-4/MPRESS4_1.IMA'};
metab_data = [sub01(:), sub02(:)]; % Make an M x N cell array
metab_data = fullfile(data_dir, metab_data); % It is good practice to include the full pathname
% Now we do the same for the water reference data. Because of how file
% joining is currently coded in Gannet, there needs to be the same number
% of water reference files per subject as the metabolite data.
sub01_w = {'sub-01-1_w/WATREF1_1.IMA', ...
'sub-01-2_w/WATREF2_1.IMA', ...
'sub-01-3_w/WATREF3_1.IMA', ...
'sub-01-4_w/WATREF4_1.IMA'};
sub02_w = {'sub-02-1_w/WATREF1_1.IMA', ...
'sub-02-2_w/WATREF2_1.IMA', ...
'sub-02-3_w/WATREF3_1.IMA', ...
'sub-02-4_w/WATREF4_1.IMA'};
water_data = [sub01_w(:), sub02_w(:)];
water_data = fullfile(data_dir, water_data);
anat = {'sub-01_T1w.nii', 'sub-02_T1w.nii'};
MRS = GannetLoad(metab_data, water_data);
MRS = GannetFit(MRS);
MRS = GannetCoRegister(MRS, anat);
MRS = GannetSegment(MRS);
MRS = GannetQuantify(MRS);
```