Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve dummy data when opening mastodon project with missing images (Issue 206) #210

Merged
merged 9 commits into from
Jan 5, 2023

Conversation

stefanhahmann
Copy link
Collaborator

Resolves #206

@stefanhahmann
Copy link
Collaborator Author

@maarzt this pull request is in draft mode for now. please test it.

@maarzt
Copy link
Contributor

maarzt commented Nov 21, 2022

Hello Stefan,

It works exactly as we discussed it, that's great. I didn't had a look into the code for now. But I noticed that the message dialog that is shown to the user is a little bit confusing:
image

Maybe a dialog like this would be better:

  • Title: Mastodon - Image data not found.

  • Icon: Warning Message

  • Text:
    Mastodon could not find the images associated with this project.
    This file was not found:
    /path/to/file/not/found/dataset.xml

    It is still possible to open the project. You won't be able to see the image data, but you can still view and modify the tracking data.

    Would you like to open the project without image data?

  • Buttons: [Open Project] [Cancel]

@stefanhahmann
Copy link
Collaborator Author

stefanhahmann commented Nov 21, 2022

Good idea. Applied suggested changes in a further commit.

@stefanhahmann stefanhahmann marked this pull request as ready for review November 21, 2022 11:31
@maarzt maarzt self-requested a review November 21, 2022 11:40
@stefanhahmann
Copy link
Collaborator Author

Visualisation of new behaviour:

  • issue-216-1
  • issue-216-2

Copy link
Contributor

@maarzt maarzt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I very much like how well this works. I think it's a big improvement in terms of user experience.

There are still some things that I would like to improve. The code for opening a mastodon project is already quite complex, and would like to avoid increasing the complexity. Could you do the requested changes. I would afterwards continue, try to refactor some stuff.

@maarzt
Copy link
Contributor

maarzt commented Nov 30, 2022

@stefanhahmann Please write a few sentences, how opening the spim data XML works, if the HDF5 data is missing.
I only understand parts of this. Like that the ImgLoader part has the removed from the XML, and there are some null values that need to be replaced later on. I think it would be useful having this documented in the issue or somewhere.

@tinevez
Copy link
Contributor

tinevez commented Nov 30, 2022

Hello @stefanhahmann @maarzt

I am only catching up now. I think that this PR may be duplicating work already done, by @xulman

The beta-26 can deal with missing BDV data but improperly. For instance the number of time-points is not detected correctly and the dummy data implemented with Vlado seems not to work in full (you need to resave the file for the dummy to work).
I have a gigantic dataset that starts at frame 400, but I cannot simply display the tracks nor TrackScheme if I do not have the BDV.

Maybe you want to test Vlado solution?

In Fiji, open Mastodon making sure we use the beta-26. We need the Fiji version, because it has the mastodon-tomancak artifact that contains the file path editor of Vlado.

Open a Mastodon file that points to a missing XML BDV file. Mastodon will warn that it cannot find the associated bdv file.
Go to the File > Fix image path menu item. There is a "I want dummy data instead", then "from spots". This will fix the issue, but only if you save and reload.

Please tell us what you think.

@maarzt
Copy link
Contributor

maarzt commented Dec 5, 2022

Hello @tinevez,

We are well aware of the work done so far be @xulman. This PR continues where this previous work stopped.

The goal is to simplify the user interaction. It is no longer required to re-save the Mastodon project and users don't need to enter information like pixel-size etc.

I would also like to move the code in mastodon-tomancak over to the main repository. As it would make the mastodon git repository more self contained.

The PR might fix the problems with the dataset that starts at frame 400. Could you maybe give this a try?

Bests, Matthias

@maarzt maarzt changed the title Issue 206 Improve dummy data when opening mastodon project without image - Issue 206 Dec 5, 2022
@maarzt maarzt changed the title Improve dummy data when opening mastodon project without image - Issue 206 Improve dummy data when opening mastodon project with missing images (Issue 206) Dec 5, 2022
@tinevez
Copy link
Contributor

tinevez commented Dec 5, 2022

Yes ok!
When the PR is ready we will ask Vlado if he is ok with transitioning his code with yours to the core, if that's ok.

@stefanhahmann
Copy link
Collaborator Author

@stefanhahmann Please write a few sentences, how opening the spim data XML works, if the HDF5 data is missing. I only understand parts of this. Like that the ImgLoader part has the removed from the XML, and there are some null values that need to be replaced later on. I think it would be useful having this documented in the issue or somewhere.

As discussed: No changes on the spim data XML are necessary (initially, I thought, they would be necessary, but in fact it turned out that they weren't). The process works now more or less as described in the acceptance criteria of #206

@stefanhahmann stefanhahmann force-pushed the issue-206 branch 2 times, most recently from 43f5006 to 9f40f74 Compare December 8, 2022 13:52
Copy link
Collaborator Author

@stefanhahmann stefanhahmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made some commits to consider your review comments.
Could you please review again?

@stefanhahmann stefanhahmann self-assigned this Dec 8, 2022
@maarzt maarzt marked this pull request as draft December 14, 2022 09:44
@maarzt maarzt force-pushed the issue-206 branch 2 times, most recently from 9d9db64 to 2037903 Compare January 3, 2023 14:32
…able

* In case of no image data available the user may decide, if he wants to load the project anyway to inspect the meta data / cell lineages or if he does not want to open the project at all
* When projects are saved, a copy the spim data xml is saved within the project
Windows, Linux & MacOS use different slashes in file paths. Windows
uses backward slashes, Linux & MacOS use forward slashes.

If a Mastodon project is saved on Windows, the project.xml will have
a dataset path with backward slashes like: ..\dataset.xml.
On Linux this path is not interpreted correctly. We need to manually
replace the backward slashes with forward slashes.

This commit moves the code that replaces the slashes into the class
MamutProjectIO. This makes a lot of sense, as the backward slashes
are introduced when reading the project.xml.
@maarzt
Copy link
Contributor

maarzt commented Jan 3, 2023

Hi @tinevez,

Let me summarize this PR for you, such that you have an easier time reviewing it. The goal of the PR is to streamline opening a Mastodon project, when the image data is missing. The changes will make it a lot easier to open a Mastodon project that one just got send via email, where image data is missing as usual...

The current version of Mastodon, can be started if the image data is missing. But it only starts with partly functional dummy data. In this state, only the first ten time-points of the trackscheme are visible and a new BDV window is zoomed suboptimally, since the image size incorrect. The user needs to click "File > Fix Image Path", resave and restart Mastodon in order to conveniently inspect the data.

This PR improves this situation very much. The main idea is to save a copy of the spim data XML within the Mastodon project. This backup file is called "dataset.xml.backup". If now a Mastodon project is opened and the primary image data is missing, Mastodon can read the "dataset.xml.backup" file to initialize dummy image data with the correct number of time points, image sizes and even affine image transformations. The TrackScheme and BDV windows work as expected with the now correct dummy image data.

The PR also improves the dialog that tells the user about the problem loading the image data. The dialog now tells the user what went wrong. And there is also a convenient "cancel" button.

Here is an overview of the changes made in the code:

  • New method DummySpimData.fromSpimDataXml() allows to create dummy data with correct metadata from a spim data XML. This works as follows:
    • Create a temporary copy of the spim data XML, with the <ImageLoader> entry removed
    • Open this modified XML. The result is a SpimData object with imgLoader not set.
    • Finally imgLoader is set to use the DummyImgLoader.
    • Et voila: we got a SpimData object with all metadata set correctly, buy no actual image pixel data required or loaded.
  • ProjectManager.openImageData(...) and SharedBigDataViewerData.fromSpimDataXml(...) have been refactored.
  • The dialog telling the user about problems loading image data is now in the new method ProjectManager.openWithDialog(...).
    This still allows to open a project without dialog using ProjectManager.open(...), which is useful for batch processing.
  • MamutProjectIO is now responsibly for correctly loading Windows file paths with backslashes on Linux
  • Newly added tests:
    • ProjectManagerTest: Test if the dataset.xml.backup is saved correctly.
    • StartMastodonWithMissingImageDemo: Demonstrate how Mastodon starts if image data is missing.
    • MamutProjectIOTest: Make sure Mastodon can deal with Windows and Linux file paths.
    • DummySpimDataTest & DummyImgLoaderTest

Bests,
Matthias

@maarzt maarzt requested a review from tinevez January 3, 2023 15:16
@maarzt maarzt marked this pull request as ready for review January 3, 2023 15:16
@tinevez tinevez changed the base branch from master to dev January 5, 2023 12:43
@tinevez
Copy link
Contributor

tinevez commented Jan 5, 2023

Hello all. High quality code!
Indeed, this new version does handling missing data really well and I would say, the proper way. The idea of creating a temp file is very good and very efficient. I tested the feature with image data hosted remotely and it works as expected.
Next step would probably be merging the tool to fix the image path from Vlado into the core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve dummy data when loading mastodon project without image data
3 participants