[Feature] scipy.ndimage library support in the NRP


#1

Hello,

I am currently trying to integrate a cortical model for image segmentation on the NRP.

The scipy library (or just scipy.ndimage) would be very useful for me on the NRP, because I want to use scipy.ndimage.interpolation.zoom to scale down the camera image to the dimensions of my neural network input layer. The network is very big and I would rather begin with a very low resolution (e.g. dimensions of the input layer = 5*5 pixels), just to have the network running on the NRP.

I am quite new to programmation, but I guess scipy is a very common library, so it could be useful for a lot of people!

Thank you for your reply!
Alban


#2

Hi Alban,

you can use scipy as of today. However, there is a small problem currently in the NRP that sometimes cause errors when the import is done outside a TF body. This means, you could simply import scipy inside the TF method body. Doing that will import scipy only once, so it is not as critical for performance as it may seem.

For example, I just hacked an example usage into the TF to transmit spike information to the robot controller in the very basic Husky experiment. This is the code:

@nrp.MapSpikeSink("left_wheel_neuron", nrp.brain.actors[1], nrp.leaky_integrator_alpha)
@nrp.MapSpikeSink("right_wheel_neuron", nrp.brain.actors[2], nrp.leaky_integrator_alpha)
@nrp.Neuron2Robot(Topic('/husky/cmd_vel', geometry_msgs.msg.Twist))
def linear_twist(t, left_wheel_neuron, right_wheel_neuron):
    """
    The transfer function which calculates the linear twist of the husky robot based on the
    voltage of left and right wheel neuron.
    :param t: the current simulation time
    :param left_wheel_neuron: the left wheel neuron device
    :param right_wheel_neuron: the right wheel neuron device
    :return: a geometry_msgs/Twist message setting the linear twist fo the husky robot movement.
    """
    import scipy
    clientLogger.info(repr(scipy.version.version))
    return geometry_msgs.msg.Twist(
        linear=geometry_msgs.msg.Vector3(x=20.0 * min(left_wheel_neuron.voltage, right_wheel_neuron.voltage), y=0.0,
                                         z=0.0), angular=geometry_msgs.msg.Vector3(x=0.0, y=0.0, z=100.0 * (
            right_wheel_neuron.voltage - left_wheel_neuron.voltage)))

What this code does, it simply prints out the version information from the scipy library that is supported in the platform (which is 0.17.1) to the client logger.

Nevertheless, we are working to fix this issue (that the import should be inside the method body) and make the integration of scipy available without any such a workaround.

Best,

Georg


#3

Wonderful!

Thank you a lot.