(Generated by Claude Code)
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. |
| 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; | |
| } |
| 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 |
| # 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 |
| # 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, |