<jupyter_start><jupyter_text>CellsIn this examples I'll show how to render a large number of cells in your scene. This can be useful when visualizing the results of tracking experiments after they have been aligned to the allen brain atlas reference frame.  set up<jupyter_code># We begin by adding the current path to sys.path to make sure that the imports work correctly
import sys
sys.path.append('../')
import os
import pandas as pd

# Set up VTKPLOTTER to work in Jupyter notebooks
from vtkplotter import *
embedWindow(backend=False) 

# Import variables
from brainrender import * # <- these can be changed to personalize the look of your renders

# Import brainrender classes and useful functions
from brainrender.scene import Scene
from brainrender.Utils.data_io import listdir

# Before populating the scene, we need to change the current working directory to the parent folder, 
# then we are ready to start!
os.chdir(os.path.normpath(os.path.join(os.getcwd(), os.pardir)))<jupyter_output><empty_output><jupyter_text>Get dataTo keep things interesting, we will generate N random "cells" in a number of regions of interest. These coordinates will then be used to render the cells. If you have your coordinates saved in a file (e.g. a .csv or .h5 or .pkl), you can use `Scene.add_cells_from_file` and skip this next step.<jupyter_code># Create a scene
scene = Scene(jupyter=True)

# Define in which regions to crate the cells and how many
regions = ["MOs", "VISp", "ZI"]
N = 1000 # getting 1k cells per region, but brainrender can deal with >1M cells easily. 

# Render brain regions and add transparency slider.
scene.add_brain_regions(regions, colors="ivory", alpha=.8)
scene.add_slider(brain_regions=regions)

print("\nRunning a quick experiment to get cell coordinates...")
cells = [] # to store x,y,z coordinates
for region in regions:
    region_cells = scene.get_n_random_points_in_region(region=region, N=N)
    cells.extend(region_cells)
x,y,z = [c[0] for c in cells], [c[1] for c in cells], [c[2] for c in cells]
cells = pd.DataFrame(dict(x=x, y=y, z=z))
# render cells
print("\nRendering...")
scene.add_cells(cells, color="red")
scene.render()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.0885440438156093, 'fraction_numerical': 0.005020538566864446, 'mean_word_length': 5.005479452054795, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '350007', 'license': 'MIT', 'n_tokens_mistral': 690, 'n_tokens_neox': 658, 'n_words': 278, 'path': 'Examples/notebooks/Cells.ipynb', 'repo_name': 'maithamn/BrainRender', 'size': '2191'}