PlusToolkit / PlusLib

Software library for data acquisition, pre-processing, and calibration for navigated image-guided interventions.
http://www.plustoolkit.org
Other
135 stars 103 forks source link

Clarius Ultrasound not recognized #682

Closed WHeerink closed 3 years ago

WHeerink commented 4 years ago

Hi,

I am trying to acquire images from a Clarius HD scanner through Plus Server, using the config xml from http://perk-software.cs.queensu.ca/plus/doc/nightly/user/DeviceClarius.html. However, when I run the Plus Server I get the error: "SERVER> Unknown device type: Clarius. Supported devices: 3dConnex...."

So, I've tried building Plusserver myself with the Clarius SDK included, using the instructions from https://github.com/PlusToolkit/PlusBuild/blob/master/Docs/BuildInstructionsWindows.md, but after a couple of days of trying I cannot get it to work. Is there a way for me to use a downloadable version of Plus Server that supports Clarius devices or do I need to build it myself?

Thank you! Wout

lassoan commented 4 years ago

after a couple of days of trying I cannot get it to work

If you provide more details about the problems (exact error messages, etc.) then we may be able to help.

WHeerink commented 4 years ago

Sorry for the late reply. It was not a specific error message I was running into. I was just wondering if there was a way around building it myself because I ran into different issues every time I tried something different. I've since put some more time in building Plus with Clarius enabled and I thought I succeeded, but when I try to connect to Clarius I still get the message it's an unknown device type: 052520_145711_PlusLog.txt

I used Qt 5.9.8 (I've tried different versions too) I cloned to C:\D\PlusBuild using VS2015 and switched to master branch. In branch Plus-2.8, I could not find Clarius support. I edited CMakelists.txt so that PLUS_USE_CLARIS was set to on: OPTION(PLUS_USE_CLARIUS "Provide support for Clarius Ultrasound devices" ON). Only after I did this, the option PLUS_USE_CLARIUS would appear in CMAKE gui.

Then, in CMAKE (3.17.1) gui I marked the checkbox of PLUS_USE_CLARIUS and set the Qt directory. Qt5WebKitWidgets_DIR was not found. The first time I configured I got the message saying pthread.h was not found. Additionally, I had to change some lines in FindCLARIUS.cmake otherwise it could not find the files in the specified directories. I used generator Visual Studio 14 2015 and build solution Release 32 It finally built without any errors and I am able to run PlusServerLauncher.exe and have tested it with NDI equipment. This went fine.

Can you please help me to identify if there went something wrong with building or with the config settings of Clarius.

Is there any other build related log file that I can upload?

Thanks for the Help! Wout

Sunderlandkyl commented 4 years ago

If you are compiling using the master version of Slicer, you should not need to edit CMakeLists.txt to get the PLUS_USE_CLARIUS option to appear.

I don't think that Clarius has a 32-bit dll, so you will likely need to compile using 64-bit. What version of the Clarius listen SDK do you have?

WHeerink commented 4 years ago

I'm pretty sure that the option wasn't there without editing CMakeListst.txt, but then again I've switched between branches several times, so maybe I mixed it up. I haven't tried 64-bit because I wanted compatibility with other devices and I figured that 32-bit would give me the most options.

I got the most recent Clarius listen SDK from https://github.com/clariusdev/listener. I guess that's v6.1.5

I will delete all files and try again with 64-bit and let you know how that works out. Thanks!

WHeerink commented 4 years ago

I installed Qt 5.9.9 msvc2015_64 and tried with the 64-bit generator in Cmake and configuration platform Release x64 in VS2015. Clarius and PlusApp, unfortunately, failed to build. Here's the relevant part of the building output: Build output.txt

I noticed in line 12 it said "-- Detected platform: Win32" Do I need to use the 64-bit version of Visual studio too?

Thanks!

Sunderlandkyl commented 4 years ago

error C3861: 'visibility': identifier not found

This error indicates that something is going on with the LISTEN_EXPORT definition. With Visual Studio, it should be __declspec(dllimport), not __attribute__((visibility("default"))).

I'll try compiling on my PC with the same settings and see if I can figure out the error.

Sunderlandkyl commented 4 years ago

I did not encounter the error when I compiled Plus locally.

If you open the listen_export.h file in your PlusLib solution, it should look like this:

image

What other devices do you need to have access to? I can add Clarius support to the nightly packages.

WHeerink commented 4 years ago

That's odd. When I opened listen_export.h from Clarius SDK in the PlusLib solution it looks like this: image

I've downloaded the Clarius SDK on April 24th. I've downloaded the files again and now they correspond to listen_export.h you sent. I'm not sure why there's a difference.

After some changes in the folder structure I managed to build Plus. I did have to disable Phidget Spatial Tracker, because I got some errors from that. I guess it's not 64 bit compatible?

I mostly use NDI Auraro together with BK ultrasound, sometimes Phidget Spatial Tracker or Calypso tracking system. But for now I plan to use Clarius together with NDI, so both 64-bit.

Anyway, I tested Plus and was able to connect to the Clarius transducer and stream to Slicer, so that's a success! Thank you for your help!

WHeerink commented 4 years ago

Hi, I'm not sure if I need to open a new topic for this, but I've got an additional question regarding Clarius. From the Clarius SDK I read that the following image information is provided with each image frame: Width, height, bit per pixel, microns per pixel, and time frame. Is there a way to get this info via Plus and send it to Slicer, just like with BK? Thanks!

Sunderlandkyl commented 4 years ago

You can see the callback where the info is received from Clarius in the vtkPlusClarius::SaveDataCallback function. https://github.com/PlusToolkit/PlusLib/blob/8e773d81a482a9718bb0ab22124f2b38841fe7a3/src/PlusDataCollection/Clarius/vtkPlusClarius.cxx#L605

Most of the data is sent as part of the image (width/height/bits), or as part of the outgoing message (timestamp). Microns per pixel is not sent from Plus, although you can see what the value is by starting Plus with log level trace. https://github.com/PlusToolkit/PlusLib/blob/8e773d81a482a9718bb0ab22124f2b38841fe7a3/src/PlusDataCollection/Clarius/vtkPlusClarius.cxx#L616-L617

What feature from the BK ultrasound would you like to see in the Clarius device?

lassoan commented 4 years ago

We could do what we already do for ultrasound (and partially also for BK) scanners: Set CurrentPixelSpacingMm (and if available then CurrentTransducerOriginPixels, too). Then ImageToTransducer transform would be automatically generated, and calibrated images could be sent to clients. This would allow calibrating the probe only once (at one single imaging depth), and after that during imaging depth could be freely adjusted.

WHeerink commented 4 years ago

Currently, with BK, I sent the US image without rescaling and use the string values "SpacingX" and "SpacingY" to get the PixelSpacing. Together with string "Depths" and the width of the image, I can determine transformation ImageToTransducer. Using an observer on a TextModifiedEvent I update these transformation matrices in Slicer in case the zoom is altered. I set these functions through CLI or in a start-up script.

So, basically the same as Andras suggested, but then in Slicer. This allows for a single freehand calibration using the SlicerIGT pointer method. I used multiple zoom factors (theoretically not necessary) and collected loads of points for a single calibration, which worked out really well. It would be great to have the same functionality with Clarius, too.

To realize this with Clarius, it would be necessary to be able to determine US_ImageToUS_transducer, and I'm not sure whether we can do that, with the info send through the API.

WHeerink commented 4 years ago

I checked with Clarius. The top center of the image does not change in position relative to the transducer when changing the zoom factor. So, a scaling combined with a shift half the width of the image should be sufficient for transform US_ImageToUS_transducer.

lassoan commented 4 years ago

@Sunderlandkyl Can you look into this? It seems that Plus should be able to compute ImageToTransducer transforms for BK and Clarius scanners the same way as for Ultrasonix.

Sunderlandkyl commented 4 years ago

Sure, I'll look into it.

WHeerink commented 4 years ago

Hi Kyle, do you maybe have an update regarding this functionality? Thank you!

Sunderlandkyl commented 4 years ago

It's still on my todo list, but I haven't looked into it yet.

WHeerink commented 4 years ago

Hi Kyle, have you had time to look into this issue? Thank you!

Sunderlandkyl commented 4 years ago

No, sorry. I haven't been able to look at this yet.

Marinho95 commented 3 years ago

I have looked into it and now we are able to read out the pixel spacing as a string. I changed lines 712-723 of the vtkPlusClarius.cxx file into the following code:

igsioFieldMapType customField; customField["micronsPerPixel"]= std::make_pair(igsioFrameFieldFlags::FRAMEFIELD_FORCE_SERVER_SEND,std::to_string(nfo->micronsPerPixel)); bModeSource->AddItem( _image.data(), // pointer to char array bModeSource->GetInputImageOrientation(), // refer to this url: http://perk-software.cs.queensu.ca/plus/doc/nightly/dev/UltrasoundImageOrientation.html for reference; // Set to UN to keep the orientation of the image the same as on tablet bModeSource->GetInputFrameSize(), VTK_UNSIGNED_CHAR, frameBufferBytesPerPixel, US_IMG_BRIGHTNESS, 0, device->FrameNumber, converted_timestamp, converted_timestamp, &customField );

Sunderlandkyl commented 3 years ago

@Marinho95 Awesome! Could you submit a PR with the changes?

Marinho95 commented 3 years ago

I don't really understand how to submit a PR. Isn't it possible for you to change the lines of code in the file mentioned above?

lassoan commented 3 years ago

Everyone who develops software nowadays is expected to be familiar with basics of git revision control (commit a change, push it to a repository, and send a pull request). If you are not yet familiar with this then it is a good opportunity to learn it now. A simple tutorial is available here: https://careerkarma.com/blog/git-pull-request/

Marinho95 commented 3 years ago

Thanks for the manual. I added a pull request here:

744