-
Notifications
You must be signed in to change notification settings - Fork 0
/
fix_striatum_rois.Rout
79 lines (73 loc) · 2.36 KB
/
fix_striatum_rois.Rout
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
74
75
76
77
78
79
R version 4.1.2 (2021-11-01) -- "Bird Hippie"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library("oro.nifti")
oro.nifti 0.11.0
> library("glue")
>
> sz <- Sys.getenv("sz")
> if (sz == "") sz <- "2.3"
>
>
> ##Left
> x <- readNIfTI(glue("l_striatum_tight_7Networks_{sz}mm.nii.gz"), reorient=FALSE)
> x[x==3] <- 0 # 0 voxels to work with at 2.3mm (here for smaller starting resolutions)
>
> x[x==2] <- 1 #2 -> 1
> highvals <- x[x > 2]
> highvals <- highvals - 2 # 4 ->2; 5 -> 3; etc.
> x[x > 2] <- highvals
>
> print(table(x))
x
0 1 2 3 4 5
7210226 1460 2058 1039 3095 3154
>
> writeNIfTI(x, glue("l_striatum_tight_7Networks_{sz}mm"), verbose = TRUE)
niftiExtension detected!
vox_offset = 2768
writing niftiExtension(s) at byte = 352
writing data at byte = 2768
[1] "l_striatum_tight_7Networks_1.0mm.nii.gz"
Warning message:
In .local(nim, ...) :
Class is of niftiExtension, extensions can be removed using as.nifti
>
> ##Right
> x <- readNIfTI(glue("r_striatum_tight_7Networks_{sz}mm.nii.gz"), reorient=FALSE)
> x[x==3] <- 0 #only 9 voxels to work with at 2.3mm
>
> #same renumbering as above
> x[x==2] <- 1 #2 -> 1
> highvals <- x[x > 2]
> highvals <- highvals - 2 # 4 ->2; 5 -> 3; etc.
> x[x > 2] <- highvals
>
> print(table(x))
x
0 1 2 3 4 5
7210809 1196 2540 994 3685 1808
>
> writeNIfTI(x, glue("r_striatum_tight_7Networks_{sz}mm"), verbose = TRUE)
niftiExtension detected!
vox_offset = 2768
writing niftiExtension(s) at byte = 352
writing data at byte = 2768
[1] "r_striatum_tight_7Networks_1.0mm.nii.gz"
Warning message:
In .local(nim, ...) :
Class is of niftiExtension, extensions can be removed using as.nifti
>
> proc.time()
user system elapsed
20.245 0.803 21.844