Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

1750305d-7604-4945-8433-76a5d1a596c3 2.9 KB
Raw

You have to be logged in to leave a comment. Sign In
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
  1. function cortical_thickness_3D(filename)
  2. %% cleanup
  3. cd /projectnb/npbssmic/s/Matlab_code/cortical_thickness
  4. if exist('thickness_skel_infra.tif','file')
  5. delete('thickness_skel_infra.tif')
  6. end
  7. if exist('thickness_skel_supra.tif','file')
  8. delete('thickness_skel_supra.tif')
  9. end
  10. %% Create the input image
  11. tic
  12. addpath('/projectnb/npbssmic/s/Matlab_code/ThorOCT_code/');
  13. I = TIFF2MAT(filename);
  14. I(I(:)==255) = 1;
  15. % interlopate in z (5 x upsampling to match 30 um isotropic resolution)
  16. [Xq, Yq, Zq] = meshgrid(linspace(1,size(I,2),size(I,2)), linspace(1,size(I,1),size(I,1)), linspace(1,size(I,3),size(I,3)*5));
  17. I_interp = interp3(single(I), Xq, Yq, Zq);
  18. I_interp(I_interp(:)>=0.25) = 1;
  19. I_interp(I_interp(:)<0.25) = 0;
  20. %% Create and save the line segments
  21. % The radius parameter should be a few voxels larger than the expected
  22. % maximum thickness. See the help of makeLineSegments.m for more parameters
  23. % % and parallelization options.
  24. if ~exist('LineSegments.mat','file')
  25. N = 100;
  26. L = makeLineSegments(N,10,2);
  27. save LineSegments L
  28. end
  29. %% Compute the thickness and the distance transform of the skeleton
  30. % See the help of MLI_thickness.m for parameters and parallelization options.
  31. % MLI_thickness_MEX.c must be compiled using: "mex MLI_thickness_MEX.c".
  32. % Alternatively, the compiled files can be downloaded from:
  33. % www.nitrc.org/projects/thickness
  34. load LineSegments
  35. param.threshStop = 0.3;
  36. param.numVoxStop = 1;
  37. param.numVoxValey = 0;
  38. param.useParpool = false;
  39. [Thickness, ~] = MLI_thickness(I_interp, L, param);
  40. %% Visualize the results
  41. % generate skeleton
  42. I_skel = zeros(size(I_interp));
  43. for i=1:size(I_interp,3)
  44. skel=bwskel(logical(squeeze(I_interp(:,:,i))));
  45. I_skel(:,:,i)=imdilate(skel,strel('sphere',1),'same');
  46. end
  47. % I_skel = imerode(I_interp, strel('sphere',1), 'same');
  48. ThicknessOnSkeleton = Thickness.*I_skel; % (SkeletonDistance<1) is a 2-voxel-wide skeleton mask. Eroding 'I' eliminates border artifacts.
  49. % Show the measured thickness on the outer surface of the skeleton.
  50. % figure; colormap jet;
  51. % isosurface(ThicknessOnSkeleton>0, 0, Thickness);
  52. % patch(isosurface(I_interp, 0), 'EdgeColor', 'none', 'FaceAlpha', .1);
  53. % camlight; lighting gouraud;
  54. % axis equal tight; colorbar;
  55. % title('Thickness on the outer surface of the skeleton');
  56. opt = strsplit(filename,'_');
  57. opt = opt{end};
  58. opt = strsplit(opt,'.');
  59. opt = opt{1};
  60. if strcmp(opt,'infra')
  61. MAT2TIFF(single(ThicknessOnSkeleton),'thickness_skel_infra.tif');
  62. elseif strcmp(opt,'supra')
  63. MAT2TIFF(single(ThicknessOnSkeleton),'thickness_skel_supra.tif');
  64. elseif strcmp(opt,'cortex')
  65. MAT2TIFF(single(ThicknessOnSkeleton),'thickness_skel_cortex.tif');
  66. end
  67. toc
  68. end
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...