Closed cagancayco closed 8 years ago
It looks like your mask doesn't match the size of your image: the main image is 91x109x91, but the segmentation is 182x218x182. It looks like the main image was downsampled but the segmentation wasn't. I apologize for the lack of warning in this case -- I'll try to fix that.
2016-03-01 13:06 GMT-05:00 cagancayco notifications@github.com:
Hi, I am trying to use PatchAnalysis to create structural networks for controls, but am confused as to how to get the code to work. I installed ITK and the PatchAnalysis project on a Mac OS X 10.8.5. I ran the following in the terminal and got the output shown below:
WintermarkMac7::Tue Mar 01@12:28:30//Volumes/HD4_3TB/Christina:/Volumes/HD4_3TB/Christina/patchanalysisbin/PatchAnalysis -i wc0TSN_00201.nii.gz -m AllCortMask.nii.gz -p patch -e eigen_ -s 3 -t 0.95 -n 1000 -o -f output_eigen -q output_patch -v -c 1 Verbose output. Dimensionality is 3. Attempting to find seed points. Looking for 1000 points out of [91, 109, 91] possible points. Found 1000 points in 9337 attempts. Iterator.Size() is 343 IndicesWithinSphere.size() is 123 It took 101 eigenvectors to reach 95% variance explained. Number of points within mask is 718499 PatchesForAllPointsWithinMask is 123x718499. Segmentation fault: 11
No output files are created though. I'm not sure what I'm doing wrong, any help would be greatly appreciated! I have attached the files I was using here.
AllCortMask.nii.gz https://github.com/bkandel/PatchAnalysis/files/153314/AllCortMask.nii.gz wc0TSN_002_01.nii.gz https://github.com/bkandel/PatchAnalysis/files/153315/wc0TSN_002_01.nii.gz
— Reply to this email directly or view it on GitHub https://github.com/bkandel/PatchAnalysis/issues/1.
Oh, I see. Thanks! So should I be using the subject's own grey matter mask that was generated during segmentation? I was using freesurfer's cortical mask.
Ah, I see. Yes, you should be using the subject-specific gray matter mask in the subject space (and not computing the networks in the template space with the template mask).
2016-03-01 15:29 GMT-05:00 cagancayco notifications@github.com:
Oh, I see. Thanks! So should I be using the subject's own grey matter mask that was generated during segmentation? I was using freesurfer's cortical mask.
— Reply to this email directly or view it on GitHub https://github.com/bkandel/PatchAnalysis/issues/1#issuecomment-190888200 .
Good to know, I used the attached images instead.
c1TSN_002_01.nii.gz TSN_002_01.nii.gz
Everything seemed to get written and the eigenvector image outputs look like what I expected. I am confused about how to interpret the output eigenvector and patch matrix .MHA files. My computer defaulted to opening them in mricron but I got errors about the size of the image not matching the header. I also tried opening them in a text editor, but didn't see a matrix.
They're MHA images. It's probably easiest to work with them using an ITK reader like antsImageRead from ANTsR: https://github.com/stnava/ANTsR/blob/master/R/antsImageRead.R
2016-03-01 16:45 GMT-05:00 cagancayco notifications@github.com:
Good to know, I used the attached images instead.
c1TSN_002_01.nii.gz https://github.com/bkandel/PatchAnalysis/files/153666/c1TSN_002_01.nii.gz TSN_002_01.nii.gz https://github.com/bkandel/PatchAnalysis/files/153667/TSN_002_01.nii.gz
Everything seemed to get written and the eigenvector image outputs look like what I expected. I am confused about how to interpret the output eigenvector and patch matrix .MHA files. My computer defaulted to opening them in mricron but I got errors about the size of the image not matching the header. I also tried opening them in a text editor, but didn't see a matrix.
— Reply to this email directly or view it on GitHub https://github.com/bkandel/PatchAnalysis/issues/1#issuecomment-190919981 .
Thanks, I get the following when I use the command antsImageRead("output_patch.mha"):
antsImage Pixel Type : float Components Per Pixel: 1 Dimensions : 123x16811 Voxel Spacing : 1x1 Origin : 0 0 Direction : 1 0 0 1
I tried using imagesToMatrix but it wouldn't work without a mask, and when I add the grey matter mask as the second argument R crashes. Do I need to use imagesToMatrix to extract the output patch matrix from the MHA image, and if so am I using the wrong file for the mask?
imagesToMatrix expects a list of images, but it shouldn't crash R for you. I think you can just do: img <- antsImageRead('img.mha') mymat <- as.matrix(img)
2016-03-03 13:16 GMT-05:00 cagancayco notifications@github.com:
Thanks, I get the following when I use the command antsImageRead("output_patch.mha"):
antsImage Pixel Type : float Components Per Pixel: 1 Dimensions : 123x16811 Voxel Spacing : 1x1 Origin : 0 0 Direction : 1 0 0 1
I tried using imagesToMatrix but it wouldn't work without a mask, and when I add the grey matter mask as the second argument R crashes. Do I need to use imagesToMatrix to extract the output patch matrix from the MHA image, and if so am I using the wrong file for the mask?
— Reply to this email directly or view it on GitHub https://github.com/bkandel/PatchAnalysis/issues/1#issuecomment-191892858 .
Thanks! I was able to export the matrices to text files after loading it per your instructions. I have another question about interpreting the output matrices. Is one of them the adjacency matrix, or do I use these outputs to construct it? I am confused since neither of the matrices are square, and I was expecting the adjacency matrix to be as such. Additionally, how do I determine the location of the nodes within the brain?
I apologize for all the questions! I'm just really excited to create single-subject structural networks and want to make sure I understand everything correctly. I've included the line of code I used and the verbose output just in case.
/Volumes/HD4_3TB/Christina/patchanalysisbin/PatchAnalysis -i TSN_002_01.nii.gz -m c1TSN_00201.nii.gz -p patch -e eigen_ -s 3 -t 0.95 -n 1000 -o -f output_eigen -q output_patch -v -c 1
Verbose output. Dimensionality is 3. Attempting to find seed points. Looking for 1000 points out of [256, 256, 176] possible points. Found 1000 points in 671079 attempts. Iterator.Size() is 343 IndicesWithinSphere.size() is 123 It took 93 eigenvectors to reach 95% variance explained. Number of points within mask is 16811 PatchesForAllPointsWithinMask is 123x16811. Recorded patches for all points. vectorizedSamplePatchMatrix is 1000x123 It took 102 eigenvectors to reach 95% variance explained. Computing regression. Average percent error is 10.2428%, with max of 29.2611%.
No worries at all about the questions!
The output from the patch analysis is just the mapping from voxel space to the patch representation space. To create an adjacency matrix, you'll still need to look at voxel-wise correlations between those two representations and average over an ROI. The adjacency matrix will be, for each pair of ROI's, what the mean correlation is between the voxels in each of the ROI's.
2016-03-09 16:12 GMT-05:00 cagancayco notifications@github.com:
Thanks! I was able to export the matrices to text files after loading it per your instructions. I have another question about interpreting the output matrices. Is one of them the adjacency matrix, or do I use these outputs to construct it? I am confused since neither of the matrices are square, and I was expecting the adjacency matrix to be as such. Additionally, how do I determine the location of the nodes within the brain?
I apologize for all the questions! I'm just really excited to create single-subject structural networks and want to make sure I understand everything correctly. I've included the line of code I used and the verbose output just in case.
/Volumes/HD4_3TB/Christina/patchanalysisbin/PatchAnalysis -i TSN_002_01.nii.gz -m c1TSN_00201.nii.gz -p patch -e eigen_ -s 3 -t 0.95 -n 1000 -o -f output_eigen -q output_patch -v -c 1
Verbose output. Dimensionality is 3. Attempting to find seed points. Looking for 1000 points out of [256, 256, 176] possible points. Found 1000 points in 671079 attempts. Iterator.Size() is 343 IndicesWithinSphere.size() is 123 It took 93 eigenvectors to reach 95% variance explained. Number of points within mask is 16811 PatchesForAllPointsWithinMask is 123x16811. Recorded patches for all points. vectorizedSamplePatchMatrix is 1000x123 It took 102 eigenvectors to reach 95% variance explained. Computing regression. Average percent error is 10.2428%, with max of 29.2611%.
— Reply to this email directly or view it on GitHub https://github.com/bkandel/PatchAnalysis/issues/1#issuecomment-194508802 .
Okay, I think I understand how to make the adjacency matrix. I guess my question now is how do I use the outputs to get the voxel-wise correlations? Do I map from voxel to patch space, calculate the correlations, then map back to voxel space? I think my biggest roadblock is that I still don't understand what the output matrices contain or how to use them to map from voxel space to patch representation space and vice versa. If you think it would help to point to specific equations, I am using this as my guide: http://picsl.upenn.edu/wp-content/uploads/2014/02/StructuralNetworks.pdf.
Sorry for the delay in response. The way I think about it is like this: The patch projections contain a vector description of the patch surrounding each voxel. For two voxels i and j, the similarity between i and j is the similarity of the structure for i and j, as encoded in the patch projection matrix. So to be concrete, say eigenpatch 1 contains a strong straight gradient. Then the similarity of the projection of i and j on the first eigenpatch will show how similar the "strong vertical gradient-ness" of the two patches is. Computing the correlation across the projections will give you a measure of how structurally similar the two voxels are.
So pseudocode for constructing a correlation matrix would look like this:
similarity_matrix = matrix(number_of_voxels, number_of_voxels) for each i, j in 0..number_of_voxels: similarity_matrix[i, j] <- correlation(patch_projection(i), patch_projection(j))
Does that make sense?
2016-03-10 10:22 GMT-05:00 cagancayco notifications@github.com:
Okay, I think I understand how to make the adjacency matrix. I guess my question now is how do I use the outputs to get the voxel-wise correlations? Do I map from voxel to patch space, calculate the correlations, then map back to voxel space? I think my biggest roadblock is that I still don't understand what the output matrices contain or how to use them to map from voxel space to patch representation space and vice versa. If it helps, I am using this as my guide: http://picsl.upenn.edu/wp-content/uploads/2014/02/StructuralNetworks.pdf.
— Reply to this email directly or view it on GitHub https://github.com/bkandel/PatchAnalysis/issues/1#issuecomment-194902484 .
Thank you so much! I was able to create the adjacency matrix.
Great! Very happy to hear.
2016-03-16 10:53 GMT-04:00 cagancayco notifications@github.com:
Thank you so much! I was able to create the adjacency matrix.
— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/bkandel/PatchAnalysis/issues/1#issuecomment-197365653
UPDATE: never mind, I think I solved my problem by symmetrizing my matrix.
Just curious, when working with the AAL atlas did you find any ROI-to-ROI correlations that ended up being zero? I want to compare the structural networks to functional networks but am not sure how to interpret these zero values, especially since my functional connectivity matrices are more continuous.
I did not find any that were zero.
2016-04-01 13:43 GMT-04:00 cagancayco notifications@github.com:
Just curious, when working with the AAL atlas did you find any ROI-to-ROI correlations that ended up being zero? I want to compare the structural networks to functional networks but am not sure how to interpret these zero values, especially since my functional connectivity matrices are more continuous.
— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/bkandel/PatchAnalysis/issues/1#issuecomment-204485535
Hi, I am trying to use PatchAnalysis to create structural networks for controls, but am confused as to how to get the code to work. I installed ITK and the PatchAnalysis project on a Mac OS X 10.8.5. I ran the following in the terminal and got the output shown below:
WintermarkMac7::Tue Mar 01@12:28:30//Volumes/HD4_3TB/Christina:/Volumes/HD4_3TB/Christina/patchanalysisbin/PatchAnalysis -i wc0TSN_00201.nii.gz -m AllCortMask.nii.gz -p patch -e eigen_ -s 3 -t 0.95 -n 1000 -o -f output_eigen -q output_patch -v -c 1 Verbose output. Dimensionality is 3. Attempting to find seed points. Looking for 1000 points out of [91, 109, 91] possible points. Found 1000 points in 9337 attempts. Iterator.Size() is 343 IndicesWithinSphere.size() is 123 It took 101 eigenvectors to reach 95% variance explained. Number of points within mask is 718499 PatchesForAllPointsWithinMask is 123x718499. Segmentation fault: 11
No output files are created though. I'm not sure what I'm doing wrong, any help would be greatly appreciated! I have attached the files I was using here.
AllCortMask.nii.gz wc0TSN_002_01.nii.gz