clariusdev / mobileapi

Android API Allowing IPC with the Clarius App
https://www.clarius.com
BSD 3-Clause "New" or "Revised" License
12 stars 4 forks source link

Receiving/Exporting Raw Data . #14

Closed shawaf closed 2 years ago

shawaf commented 2 years ago

App Version : Clarius App Version : 8.5.1 Mobile API Version : Version 8.0.1 Mobile OS version : Android 11

Problem : 1- I had an issue on Exporting case to local storage , though the app has all Storage Permission But nothing after exporting at Files >> Pictures >> Clarius Export >> Case 2- When trying to use DOWNLOAD_RAW_DATA command at mobile API it returns with null (Package Size 0)

MobileAPIIssue

I think there's something needs to add about access storage permissions for Android Versions >= 30 . https://developer.android.com/about/versions/11/privacy/storage

julien-l commented 2 years ago

Hello,

  1. I am assuming you are referring to exporting images from the Clarius app, not from the QuickStart app in this repository. The version you are using 8.5.1 should be compatible with the recent privacy changes introduced in Android (scoped storage in particular). If export does not work for you, please contact support at https://support.clarius.com/.

  2. Raw data download from the Mobile API uses a FileProvider (https://developer.android.com/reference/androidx/core/content/FileProvider) so it is not affected by storage permissions. If you get a package size 0, it probably means the Clarius app did not collect any raw data. Note that sending the DOWNLOAD_RAW_DATA command does not start raw data acquisition, it must be done manually from the app.

Let me know if this helps.

shawaf commented 2 years ago

1- Yes exporting from the clarius app and it's not working at all and I also noticed that the app is not downloading anything after every scan it will freeze without downloading that's why I thought it may be the new storage permission thing.

2- This issue is depending I guess on the first issue cause clarius app is not downloading data so the mobile API is returning with 0 package size. and sure I'm running the command manually after finish the scan and at the freeze time.

julien-l commented 2 years ago
  1. Clarius app 8.5.1 includes the necessary changes to support Android 10 and 11 privacy features, in particular the scoped storage permission. I just tested again, images are exported in Documents -> Clarius Export. If your problem persists, please contact support at https://support.clarius.com/ so we can have access to your logs.

  2. File sharing in the Mobile API is not affected by scoped permissions. The 0 package size suggests that no raw data was downloaded from the scanner. Instructions to acquire raw data can be found here https://github.com/clariusdev/signalproc (note the icons have changed in 8.5.1).

shawaf commented 2 years ago

1- Oh Found them , they were previously stored on Pictures >> Clarius Export ( That will require to change paths in all our apps ) .

2- Tried everything still nothing , I will contact support .

julien-l commented 2 years ago

I am glad you found the exports and resolved the first issue. Keep in mind that 8.5.1 is still a beta software.

Regarding the raw data download: can you detail what you tried? I want to isolate the source of the problem, the first step is to ensure the app indeed acquired raw data and collected it from the scanner.

  1. Now that you have access to the exports, can you confirm there is an archive with the raw data?
  2. Inspect log messages sent by the Clarius App to the Android system logs with logcat; search messages with prefix MobileAPI and look for error messages.
  3. Ensure the replyTo parameter is set with your Messenger when sending a DOWNLOAD_RAW_DATA message.
shawaf commented 2 years ago

1- No Archive file (.tar) though I'm taken scans with data . 2- Yes check screenshot attached . 3- yes I'm sure of that , I'm following exactly the same as the example .

Notes : 1- Check screenshot you will find no option for activating capture raw data as old versions. 2- No Download happens from transducer to mobile after scan happens and in freeze time as before though I'm sure there's patient data I took with it . Screenshot_20211018-165524

Screenshot_20211015-143227

image

shawaf commented 2 years ago

Hello @julien-l , Any Update about this issue ?

clariusk commented 2 years ago

this is updated in an upcoming release, thanks

julien-l commented 2 years ago

Hi @shawaf the new Clarius app version 8.6 was release today as well as the updated Mobile API. You can try this new version.

If you are still unable to download raw data, I would like to see the messages posted by the Clarius app itself in the general logcat output, not only the messages by the example app. In Android Studio for example, open the "logcat" tab and select "no filters" in the filter list. The Clarius app prefixes all the Mobile API messages with the MobileApi keyword so you can filter only the relevant messages. See the attached screenshot.

Screen Shot 2021-11-09 at 15 55 06
shawaf commented 2 years ago

Here's a snapshot from logcat with no filter and MobileApi Tag

image

-My Current Flow that fails is Start Clarius -> Connect using mobile API from the app -> Take Cine -> Auto Freeze happens and this the time I send Download Raw Data  -I have noticed that If I took the scan inside clarius app and it downloads the raw data and then goes back to the mobile API example and sends Download Raw Data it works.  -Also sometimes if I unfreeze the screen and start downloading it works but with extra data maybe that's because when unfreeze happens buffered filled with more data.

My App is using the following :

Use Case: Take the cine from our app download it and do some processing and then take the next cine and so on. Flow : I'm taking this flow to achieve that 

shawaf commented 2 years ago

Hello @julien-l , any update about this ? is there something I'm missing here ?

julien-l commented 2 years ago

Hi, I can see from the logs that the Clarius app receives the request to download raw data: V/MobileApi: handleMessage(10), with 10 corresponding to MSG_DOWNLOAD_RAW_DATA and then no error, so it suggests there is no raw data to download.

Here is my workflow with app version 8.6:

https://user-images.githubusercontent.com/1530763/142066514-ed412e44-a974-4387-b98a-11825e052a7d.mov

shawaf commented 2 years ago

From your workflow i found i'm doing the download step differently while app is freeze and that's mostly why it's not downloading So I have 2 questions to integrate this flow with my app : 1- About Clarius App: Is there a way I can make auto (freeze = false) after download data finish in clarius app ? 2- How can I monitor the download progress that happening in clarius app from my app ? so I can unfreeze manually and start my app download data part . (i'm not spliting screen while my app is working and that's why i'm not seeing the progress ).

A nother suggestion that will save my life is : if clarius app supports download the raw data from transducer directly to custom folder instead of caching private folder , so I can avoid this scenario of download data by clarius app first and then get it by my external app to a custom folder .

shawaf commented 2 years ago

Hi Julian , sorry for the nagging but about my last questions , is there a something that can help ?

julien-l commented 2 years ago

Hello,

1- About Clarius App: Is there a way I can make auto (freeze = false) after download data finish in clarius app ?

Settings > Auto Scan Post Cine

2- How can I monitor the download progress that happening in clarius app from my app ?

Not currently possible to get the progression of the transfer from the probe to the Clarius app via the Mobile API. MSG_RAW_DATA_DOWNLOAD_PROGRESS is the progress from Clarius app to Mobile API.

if clarius app supports download the raw data from transducer directly to custom folder instead of caching private folder

I see how it would simplify your workflow. Not sure if/how/when it can be done but I will make a feature request. Thanks for the suggestion!

shawaf commented 2 years ago

@julien-l Hello Julien , I'm trying to download data between start : end frame timestamp and I'm currently sending the current device timestamp but this gives me NullPointer Exception so I probably i'm sending the wrong timestamp , Is there example of the timestamp I should send with download action ?

image

julien-l commented 2 years ago

Hello, the start and end timestamps act as a kind of filter on the downloaded frames: only the frames with a timestamp falling in [start end] will be downloaded. The timestamps should correspond to the acquired frames' timestamps, not to your device time. Also note that the frames' timestamps are arbitrary and do not correspond to any calendar time, in particular this is not a UNIX timestamp. In your case you cannot really guess the appropriate timestamps because you have not downloaded the acquired frames yet, so you should probably leave the default value (0, download all), and do any filtering later.

shawaf commented 2 years ago

Oh i got it , But the reason why i wanted to use it is when downloading the data using the download command and compare the result .tar with the one I get when (End Exam -> Export to Local Storage ) , I found it's really different in depth , width as it was like another data I got . So how should I get the right same data as clarius app export?

Note the flow I'm taking in my app is : 1- Send Capture Cine . 2- Wait clarius app for downloading data 3- Unfreeze 4- Start Download Command .

clariusk commented 2 years ago

For 'start' and 'end', you should also be able to figure out what timestamp values are valid based on the 'tm' field passed in each streamed image in ProcessedImageInfo. During a scan, assume the last 10 seconds or so will have valid raw data buffered on the probe, so you should then use any frame timestamps that correspond.

shawaf commented 2 years ago

@clariusk It's a great suggestion, I just tried it and i got these values to send with the download command :

For Ex : Start (62775590066) , End(67826074187)

But I still get the same error of null pointer exception, so i'm assuming if any of the frames range i send is not having a valid raw data it returns a null pointer exception or any other reason could be ?

julien-l commented 2 years ago

Null pointer exception is probably caused by the Quickstart application because no data was returned. Try to change line 87 in RawDataDownload.java from:

if (!packageExtension.isEmpty())

To:

if (packageExtension && !packageExtension.isEmpty())

This should fix the exception but not the download. If the download reply is empty, it most likely means no frame matched the timestamps.

shawaf commented 2 years ago

yes checking for null value fixed it , so back to the main issue . Download raw data using mobile API is not resulting the same data i got with clarius app (Export to local storage) even i used a timestamp range i got of image tm field is returning empty reply . What's the prober solution for that ?

julien-l commented 2 years ago

when downloading the data using the download command and compare the result .tar with the one I get when (End Exam -> Export to Local Storage ) , I found it's really different in depth , width as it was like another data I got .

Did you compare the timestamps? If the timestamps are different, they are different frames.

clariusk commented 2 years ago

Also, make sure buffering is turned on, and double check that you are able to download raw data when not using the API - ie. just on the Clarius App interface.

shawaf commented 2 years ago

@julien-l yes it's different that's why I was trying to set the frames range when I started the question today, I found my timestamps started after the clarius one ends not even close. I also tried to use a quick start sample and it gives me the same result.

@clariusk definitely I have a production app running that totally depends on the raw data so I'm always making sure that RF mode is selected and the raw data button is activated.