Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

PreProMainStack.m 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. function [MGwanted,MGvolume,res]=PreProMainStack(load_main,Animal,Cell,m,range,int,loadMainStack)
  2. info = imfinfo(strcat(load_main,Animal,'\',Cell,'\',loadMainStack,'.tif'));
  3. MGstack = zeros(info(1).Width,info(1).Height, range(2) - range (1)+1);
  4. count=0;
  5. for r=range(1):range(2)
  6. count=count+1;
  7. mg = imread(strcat(load_main,Animal,'\',Cell,'\',loadMainStack,'.tif'), r, 'Info', info);
  8. background = imopen(mg, strel('disk',50));
  9. mg = mg - background;
  10. MGstack(:,:,count) = mg;
  11. clear mg
  12. end
  13. [~, BWmg] = hysteresis3d(MGstack, 0.1, 0.5, 26); % thresholds the microglia image with lower threshold 0.1 and upper threshold 0.5 and segments it with connectivity of 26, only returns the hysteresis images (~negates first output)
  14. clear MGstack
  15. [MGstack] = ordfilt3D(BWmg,14); % filters the BW microglia stack for 26 neighbours
  16. clear BWmg
  17. [MGstack_label, MGnum] = bwlabeln (MGstack);% labels parts of one distinct microglia with one number
  18. size_mg = sum(MGstack_label(:)== 1:MGnum); % sums up pixels with the same number (so pixels of each microglial part or microglia)
  19. [MGvolume, idx] = max(size_mg);% returns the volume and the index of the highest pixel volume
  20. if m==2
  21. size_mg(1,idx)=0;
  22. clear idx MGvolume
  23. [MGvolume, idx] = max(size_mg);
  24. elseif m==3
  25. size_mg(1,idx)=0;
  26. clear idx MGvolume
  27. [MGvolume, idx] = max(size_mg);
  28. size_mg(1,idx)=0;
  29. clear idx MGvolume
  30. [MGvolume, idx] = max(size_mg);
  31. end
  32. MGwanted = (MGstack_label == idx);% makes stack from the original microglia stack but with only the desired microglia displayed as logical one (so only it is shown)
  33. res.pixel_width_um = info(1).Width./info(1).XResolution;% enter your pixel width in um (get from info in .tif)
  34. res.pixel_height_um = info(1).Height./info(1).YResolution; % enter your pixel heigth in um
  35. res.pixel_depth_um = int; % enter the step size (slice thickness) in um
  36. MGvolume = MGvolume* (res.pixel_width_um*res.pixel_height_um*res.pixel_depth_um);% calculates the volume in um of the microglia from the volume in pixels