<commit_before>#!/usr/bin/env python

"""
the actual renderer class to max project 3d data

the modelView and projection matrices are compatible with OpenGL

usage:

rend = VolumeRenderer((400,400))

Nx,Ny,Nz = 200,150,50
d = linspace(0,10000,Nx*Ny*Nz).reshape([Nz,Ny,Nx])

rend.set_data(d)
rend.set_units([1.,1.,.1])
rend.set_projection(projMatPerspective(60,1.,1,10))
rend.set_modelView(dot(transMatReal(0,0,-7),scaleMat(.7,.7,.7)))

out = rend.render()



author: <NAME>
email: <EMAIL>
"""

import logging
logger = logging.getLogger(__name__)



import os
from PyOCL import cl, OCLDevice, OCLProcessor, cl_datatype_dict
from scipy.misc import imsave
from numpy import *
import numpy as np
from scipy.linalg import inv


from spimagine.transform_matrices import *
import spimagine

import sys


def absPath(myPath):
    """ Get absolute path to resource, works for dev and for PyInstaller """
    try:
        # PyInstaller creates a temp folder and stores path in _MEIPASS
        base_path = sys._MEIPASS
        return os.path.join(base_path, os.path.basename(myPath))
    except Exception:
        base_path = os.path.abspath(os.path.dirname(__file__))
        return os.path.join(base_path, myPath)

class VolumeRenderer:
    """ renders a data volume by ray casting/max projection

    usage:
               rend = VolumeRenderer((400,400))
               rend.set_data(d)
               rend.set_units(1.,1.,2.)
               rend.set_modelView(rotMatX(.7))
    """

    def __init__(self, size = None):
        """ e.g. size = (300,300)"""

        try:
            # simulate GPU fail...
            raise Exception()

            self.dev = OCLDevice(useGPU = True,
                                 useDevice = spimagine.__OPENCLDEVICE__)

            self.isGPU = True
            self.dtypes = [np.float32,np.uint16]
<commit_msg>minor<commit_after>#!/usr/bin/env python

"""
the actual renderer class to max project 3d data

the modelView and projection matrices are compatible with OpenGL

usage:

rend = VolumeRenderer((400,400))

Nx,Ny,Nz = 200,150,50
d = linspace(0,10000,Nx*Ny*Nz).reshape([Nz,Ny,Nx])

rend.set_data(d)
rend.set_units([1.,1.,.1])
rend.set_projection(projMatPerspective(60,1.,1,10))
rend.set_modelView(dot(transMatReal(0,0,-7),scaleMat(.7,.7,.7)))

out = rend.render()



author: <NAME>
email: <EMAIL>
"""

import logging
logger = logging.getLogger(__name__)



import os
from PyOCL import cl, OCLDevice, OCLProcessor, cl_datatype_dict
from scipy.misc import imsave
from numpy import *
import numpy as np
from scipy.linalg import inv


from spimagine.transform_matrices import *
import spimagine

import sys


def absPath(myPath):
    """ Get absolute path to resource, works for dev and for PyInstaller """
    try:
        # PyInstaller creates a temp folder and stores path in _MEIPASS
        base_path = sys._MEIPASS
        return os.path.join(base_path, os.path.basename(myPath))
    except Exception:
        base_path = os.path.abspath(os.path.dirname(__file__))
        return os.path.join(base_path, myPath)

class VolumeRenderer:
    """ renders a data volume by ray casting/max projection

    usage:
               rend = VolumeRenderer((400,400))
               rend.set_data(d)
               rend.set_units(1.,1.,2.)
               rend.set_modelView(rotMatX(.7))
    """

    def __init__(self, size = None):
        """ e.g. size = (300,300)"""

        try:
            # simulate GPU fail...
            # raise Exception()

            self.dev = OCLDevice(useGPU = True,
                                 useDevice = spimagine.__OPENCLDEVICE__)

            self.isGPU = True
            self.dtypes = [np.float32,np.uint16]

{'fraction_non_alphanumeric': 0.11596958174904944, 'fraction_numerical': 0.030418250950570342, 'mean_word_length': 2.789094650205761, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1045520', 'n_tokens_mistral': 1291, 'n_tokens_neox': 1201, 'n_words': 292}