Skip to content

Instantly share code, notes, and snippets.

View ebrahimebrahim's full-sized avatar
🫓

Ebrahim Ebrahim ebrahimebrahim

🫓
View GitHub Profile
@ebrahimebrahim
ebrahimebrahim / vtkMRMLMarkupsStorageNodeTest2-fix.md
Last active March 11, 2026 21:43
Analysis of vtkMRMLMarkupsStorageNodeTest2 failure with VTK 9.6 (rapidjson ODR violation)

(Generated by Claude Code)

vtkMRMLMarkupsStorageNodeTest2 failure analysis

Symptom

The test writes a markups JSON file containing NaN (for an undefined control point position), then reads it back. The read fails:

"""Slicer integration for abcdmicro resources.
This module provides resources that wrap 3D Slicer MRML scene objects,
allowing seamless integration between abcdmicro's Resource abstraction
and Slicer's visualization and analysis capabilities.
SlicerVolumeResource is considered "loaded" (is_loaded=True) because the
data lives in memory (Slicer's VTK structures). This is analogous to
InMemoryVolumeResource, just with VTK as the backing storage instead of
numpy arrays.
@ebrahimebrahim
ebrahimebrahim / slicer-curved-planar-reformat-demo.py
Created November 25, 2025 15:13
Non-working Slicer curved planar reformat module test
slicer.mrmlScene.Clear(0)
# Check that registration of "ResampleScalarVectorDWIVolume" worked.
resamplerName = "ResampleScalarVectorDWIVolume"
generalizedReformatLogic = slicer.modules.generalizedreformat.logic()
generalizedReformatLogic.SetMRMLApplicationLogic(slicer.app.applicationLogic())
found = generalizedReformatLogic.IsVolumeResamplerRegistered(resamplerName)
print(f"{resamplerName!r} was{'' if found else ' NOT'} found in module logic")
# Check that we can find an existing vtkMRMLSliceLogic.
<!DOCTYPE html>
<html>
<head>
<title>Snake Game</title>
<script src="https://code.jquery.com/jquery-1.11.3.js"></script>
<style>
html, body {
height: 100%;
margin: 0;
}
@ebrahimebrahim
ebrahimebrahim / running_mean.py
Created November 24, 2022 20:15
running mean with numpy
import numpy as np
from numpy.typing import NDArray
class RunningMean:
"""Like numpy.mean but aggregates data in chunks at a time."""
def __init__(self, axis=None, keepdims=False):
"""For axis and keepdims, see the documentation of these arg names in numpy.mean"""
self.axis=axis
self.keepdims=keepdims
@ebrahimebrahim
ebrahimebrahim / cambria_math_install.sh
Created October 19, 2022 15:56
install cambria math and times new roman fonts on ubuntu
# some annoying document formatting requirements made me to this in tex:
# \setmathfont{Cambria Math}
# \setmainfont{Times New Roman}
# and of course these microsoft fonts are not found when compiling with xelatex on ubuntu
# this gist helps set up the texlive environment in ubuntu to find the fonts
# thanks to maxwelleite: https://gist.github.com/maxwelleite/10774746
# their script is way better and more automated, but I didn't want to sudo an entire script,
# so below I have extracted the commands I want and made it clear where sudo is needed
# I recommend running the below one by one to check that each step works
@ebrahimebrahim
ebrahimebrahim / slicer_plot_data.py
Last active March 16, 2022 19:09
use a class to manage the nodes involved in a slicer plot view
# To try this example, save this to a file slicer_plot_data.py, then execute Slicer from the command line
# with the arguments `--python-script slicer_plot_data.py`.
import slicer, qt, vtk
PLOT_TYPES = {
"line" : slicer.vtkMRMLPlotSeriesNode.PlotTypeLine,
"bar" : slicer.vtkMRMLPlotSeriesNode.PlotTypeBar,
"scatter" : slicer.vtkMRMLPlotSeriesNode.PlotTypeScatter,
"scatterbar" : slicer.vtkMRMLPlotSeriesNode.PlotTypeScatterBar,