cwatson / brainGraph

Graph theory analysis of brain MRI data
173 stars 51 forks source link

connectivity matrices from ExploreDTI #18

Closed GerardYu closed 4 years ago

GerardYu commented 4 years ago

I've gotten some connectivity matrices from ExploreDTI using the AAL atlas. These were originally .mat files, I 've converted them into .csv files. I tried to do a create_mats, but I end up with the following error:

Error in scan(x, what = numeric(0), n = Nv * ncols, quiet = TRUE) : scan() expected 'a real', got '"","CM.1","CM.2","CM.3","CM.4","CM.5","CM.6","CM.7","CM.8","CM.9","CM.10","CM.11","CM.12","CM.13","CM.14","CM.15","CM.16","CM.17","CM.18","CM.19","CM.20","CM.21","CM.22","CM.23","CM.24","CM.25","CM.26","CM.27","CM.28","CM.29","CM.30","CM.31","CM.32","CM.33","CM.34","CM.35","CM.36","CM.37","CM.38","CM.39","CM.40","CM.41","CM.42","CM.43","CM.44","CM.45","CM.46","CM.47","CM.48","CM.49","CM.50","CM.51","CM.52","CM.53","CM.54","CM.55","CM.56","CM.57","CM.58","CM.59","CM.60","CM.61","CM.62","CM.63","CM.64","CM.65","CM.66","CM.67","CM.68","CM.69","CM.70","CM.71","CM.72","CM.73","CM.74","CM.75","CM.76","CM.77","CM.78","CM.79","CM.80","CM.81","CM.82","CM.83","CM.84","CM.85","CM.86","CM.87","CM.88","CM.89","CM.90"'

cwatson commented 4 years ago

Hi @GerardYu , those files should instead be space- or tab-separated (although CSV might work). But the error is probably due to the column names, so remove column names and it should work.

GerardYu commented 4 years ago

I removed the column names it still doesn't work

filelist<- c("CMtracts/J019.csv","CMtracts/m041.csv") create_mats(filelist, mat.thresh=thresholds, sub.thresh=0.5) Error in scan(x, what = numeric(0), n = Nv * ncols, quiet = TRUE) : scan() expected 'a real', got '2200,28,613,78,NA,NA,808,1,NA,NA,373,NA,105,NA,NA,NA,225,NA,513,113,NA,NA,NA,NA,NA,NA,NA,NA,231,NA,NA,NA,165,153,NA,NA,9,37,22,37,NA,NA,8,NA,41,NA,7,1,85,NA,48,NA,NA,NA,13,37,1314,14,25,1,516,1,53,1,414,NA,4,NA,616,63,236,5,5,5,NA,1,482,143,11,NA,337,NA,12,NA,237,NA,NA,NA,2,4'

i'm attaching a connectivity matrix, which was a .csv file, but converted to ,xlsx for the purpose of uploading it here.

M041.xlsx

cwatson commented 4 years ago

I cannot download the file, but regardless I don't think comma-separated will work. Each element should be separated by a space (possibly a tab). I recommend saving/converting the files to be space-separated instead.

GerardYu commented 4 years ago

I tried to convert it to space delimited (.prn) it didn't work. I've checked there are equal number of rows and columns before converting to space-delimited PRN.

filelist<- c("CMtracts/M041.prn") thresholds <- seq(from=0.001, to=0.01, by=0.001) create_mats(filelist, mat.thresh=thresholds, sub.thresh=0.5) Error in base::rowSums(x, na.rm = na.rm, dims = dims, ...) : invalid 'dims' In addition: Warning message: In matrix(scan(x, what = numeric(0), n = Nv * ncols, quiet = TRUE), : data length [3335] is not a sub-multiple or multiple of the number of rows [270]

I've tried converting to tab-delimited .txt file M041.txt

it didnt work too

filelist<- c("CMtracts/M041.txt") thresholds <- seq(from=0.001, to=0.01, by=0.001) create_mats(filelist, mat.thresh=thresholds, sub.thresh=0.5) Error in base::rowSums(x, na.rm = na.rm, dims = dims, ...) : invalid 'dims'

cwatson commented 4 years ago

I am not familiar with the prn format and I don't recommend using it.

I downloaded the text file and was able to import it using scan. The error with rowSums, though, I am not sure what is causing it. The only instances of rowSums in the function have dims=2 and not dims=dims; did you change the code? Actually, create_mats really needs multiple subjects for it to work properly -- in particular, when using consensus thresholding, which is the default.

I would first try changing all the NA values to 0. The simplest way that I can think of (if ExploreDTI doesn't have an option) is to do it on the command line with the following: sed -i 's/NA/0/g' M041.txt

If that doesn't fix things, can you post the result of traceback after running for your full dataset?

GerardYu commented 4 years ago

thanks. it worked now after replacing the NAs with 0

cwatson commented 4 years ago

Glad to hear it works. I will update the User Guide to mention this issue.