nii2RData.Rd
This function can take NIfTI data file(s) (the file extension is "nii.gz" or "nii") as input (you only need to specify the name of file before extension) and transform them into RData file(s) (in the form of .RData).
nii2RData(niiFile1, resolution = "2mm", saveName = "None",
regionCode = "", niiFile2 = "", imgPath = getwd(), datPath = getwd())
niiFile1 | the NIfTI data file(s) (containing information of fMRI of patient(s)) you would like to use. If you want to read more than one file, you can either type in the name in the form of vector string, or call this function for several times. |
---|---|
resolution | the resolution of your region data. It can take "2mm" as default. If user would like to use 3mm resolution, type in "3mm". |
saveName | whether to save processed imaging data. If you do not have enough space or do not want to use space to store processed data, just type in "None" (default); otherwise you need to specify name in this argument. For example, saveName="myName.RData". |
regionCode | the region code provided by user or default. It should have 3 columns with index, region code and region name. |
niiFile2 | the NIfTI region file you would like to use. It has default NIfTI file and can be left as blank if no region file provided. |
imgPath | the directory where your NIfTI file(s) is (are) located. It chooses your current working directory as default. |
datPath | the directory where you would like to store .RData file(s). It chooses your current working directory as default. |
the processed imaging data.
This function must accept the NIfTI imaging data as argument to manipulate
the raw data to processed R data. The file extension is "nii.gz" or "nii".
You only need to specify the name of file without extension in the function argument.
For example, your interested imaging file is called "brain.nii.gz" or "brain.nii".
You only need to write niiFile1="brain" in the first argument rather than "brain.nii.gz"
or something else. The package can either use its default region code and region data
or use user-defined region information.
Here are some notes which may be useful:
(1) When reading multiple imaging files, make sure they have the same resolution,
region code and region data.
(2) If you would like to read multiple imaging files, and if you did not use
saveName="None" argument, it can sometimes take a large storage. For example,
if you read 100 files, then 100 "RData" files will be generated and thus take
a large storage space. Thus, saveName="None" is highly recommended in this case.
Xubo Yue, Chia-Wei Hsu (tester), Jian Kang (maintainer)
# \donttest{
#It will take more than 10 s to run
#write data into temp file
filePath <- tempdir()
#the nii.gz fMRI imaging file is created (toy example)
oro.nifti::writeNIfTI(brainKCCA::input_img, paste(filePath, "/", "temp", sep=""))
#read fMRI data
testcase1 <- nii2RData(niiFile1 = "temp", resolution = "3mm", imgPath = filePath)
#> Reading nii files...this progress may take a long time...
#>
|
| | 0%
|
|= | 1%
|
|= | 2%
|
|== | 3%
|
|=== | 4%
|
|==== | 5%
|
|==== | 6%
|
|===== | 7%
|
|===== | 8%
|
|====== | 9%
|
|======= | 9%
|
|======= | 10%
|
|======== | 11%
|
|======== | 12%
|
|========= | 13%
|
|========== | 14%
|
|========== | 15%
|
|=========== | 16%
|
|============ | 17%
|
|============= | 18%
|
|============= | 19%
|
|============== | 20%
|
|============== | 21%
|
|=============== | 22%
|
|================ | 22%
|
|================ | 23%
|
|================= | 24%
|
|================== | 25%
|
|================== | 26%
|
|=================== | 27%
|
|=================== | 28%
|
|==================== | 28%
|
|===================== | 29%
|
|===================== | 30%
|
|====================== | 31%
|
|====================== | 32%
|
|======================= | 33%
|
|======================== | 34%
|
|========================= | 35%
|
|========================= | 36%
|
|========================== | 37%
|
|=========================== | 38%
|
|=========================== | 39%
|
|============================ | 40%
|
|============================ | 41%
|
|============================= | 41%
|
|============================== | 42%
|
|============================== | 43%
|
|=============================== | 44%
|
|=============================== | 45%
|
|================================ | 46%
|
|================================= | 47%
|
|================================== | 48%
|
|================================== | 49%
|
|=================================== | 50%
|
|==================================== | 51%
|
|==================================== | 52%
|
|===================================== | 53%
|
|====================================== | 54%
|
|======================================= | 55%
|
|======================================= | 56%
|
|======================================== | 57%
|
|======================================== | 58%
|
|========================================= | 59%
|
|========================================== | 59%
|
|========================================== | 60%
|
|=========================================== | 61%
|
|=========================================== | 62%
|
|============================================ | 63%
|
|============================================= | 64%
|
|============================================= | 65%
|
|============================================== | 66%
|
|=============================================== | 67%
|
|================================================ | 68%
|
|================================================ | 69%
|
|================================================= | 70%
|
|================================================= | 71%
|
|================================================== | 72%
|
|=================================================== | 72%
|
|=================================================== | 73%
|
|==================================================== | 74%
|
|==================================================== | 75%
|
|===================================================== | 76%
|
|====================================================== | 77%
|
|====================================================== | 78%
|
|======================================================= | 78%
|
|======================================================== | 79%
|
|======================================================== | 80%
|
|========================================================= | 81%
|
|========================================================= | 82%
|
|========================================================== | 83%
|
|=========================================================== | 84%
|
|============================================================ | 85%
|
|============================================================ | 86%
|
|============================================================= | 87%
|
|============================================================== | 88%
|
|============================================================== | 89%
|
|=============================================================== | 90%
|
|=============================================================== | 91%
|
|================================================================ | 91%
|
|================================================================= | 92%
|
|================================================================= | 93%
|
|================================================================== | 94%
|
|================================================================== | 95%
|
|=================================================================== | 96%
|
|==================================================================== | 97%
|
|===================================================================== | 98%
|
|===================================================================== | 99%
|
|======================================================================| 100%
#> reading data 1
#>
|
| | 0%
|
|============== | 20%
|
|============================ | 40%
|
|========================================== | 60%
|
|======================================================== | 80%
|
|======================================================================| 100%
#> Completed...
#>
# }