Coder Social home page Coder Social logo

Region specific heatmaps about clearmap HOT 2 OPEN

christophkirst avatar christophkirst commented on August 17, 2024
Region specific heatmaps

from clearmap.

Comments (2)

vzickus avatar vzickus commented on August 17, 2024

I haven't tried isolating this in such a way, and without knowing the biological question you have it's hard to suggest something, but maybe you could just "crop" the full heatmap around that region?

from clearmap.

coelhocao avatar coelhocao commented on August 17, 2024

Here is how I did it.
I have a .csv file with the list of regions I want to show in the heatmap. It has to be a list with the regions' number. In the zipped registration file you download from https://idisco.info/clearmap-2/ you have a file called regions IDs.csv they have all the codes of the regions in there.

Next, in the parameter_file_template.py file, I inserted the following piece of code in the end
in the code, heatmap_ids.csv is MY list of regions of interest

# CESAR'S VARIABLES for visualizing counted cells in specific regions
outside = 0
with open('/home/cesar/Image_analysis/Python/Registration/parameter_25um/heatmap_ids.csv') as f:
    region = list(csv.reader(f, delimiter = ";"))

region = numpy.array(region, dtype = numpy.int)

Then, in the process_template.py, the piece of code that generates the heatmap and saves it

# Heat map generation
#####################
points = io.readPoints(TransformedCellsFile)
intensities = io.readPoints(FilteredCellsFile[1])

#Without weigths:
vox = voxelize(points, AtlasFile, **voxelizeParameter);
if not isinstance(vox, basestring):
  io.writeData(os.path.join(BaseDirectory, 'cells_heatmap.tif'), vox.astype('int32'));

#With weigths from the intensity file (here raw intensity):
voxelizeParameter["weights"] = intensities[:,0].astype(float);
vox = voxelize(points, AtlasFile, **voxelizeParameter);
if not isinstance(vox, basestring):
  io.writeData(os.path.join(BaseDirectory, 'cells_heatmap_weighted.tif'), vox.astype('int32'));

I replaced that whole block of code for the following:

# Heat map generation
#####################
from ClearMap.Alignment.Resampling import sagittalToCoronalData 

points = io.readPoints(TransformedCellsFile)
intensities = io.readPoints(FilteredCellsFile[1])
vox = voxelize(points, AtlasFile, **voxelizeParameter);

#### CESAR'S CODE
### In this piece, the heatmap generated affects only the regions defined in the variable region
label = io.readData(AnnotationFile);
label = label.astype('int32');
labelids = numpy.unique(label);

for l in labelids:
    if not numpy.in1d(l,region): # matches the annotation file to list of regions of interest
        outside = numpy.logical_or(outside, label == l); #this works for multiple brain regions

vox[outside] = 0;
io.writeData(os.path.join(BaseDirectory, 'cfos/overlays.mhd'), sagittalToCoronalData(vox.astype('int16')));
io.writeData(os.path.join(BaseDirectory, 'cfos/annotation_to_overlay.mhd'), sagittalToCoronalData(label.astype('int16')));

Now, just note that the heatmap is going to be saved in the coronal dimensions.
If you still want it in the sagital plan, remove the sagittalToCoronalData() function from the two last lines and you are good.

from clearmap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.