Viewers
Viewers copied to clipboard
How to turn Multiframe studies to autoplay ?
Hello All,
Multi-frame studies used to auto play as soon as it was dragged onto viewport, however it does not do that anymore.
Any advice how to enable this feature again?
Thank you in advance!! Ric
If you look at the redux state, the viewports/viewportSpecificData
looks like this:
You can write a redux selector to detect the isMultiframe
and when Viewport is first loaded, then dispatch a redux action to set cine isPlaying
to true
. Some pseudo code:
function useAutoPlayCine() {
const dispatch = useDispatch();
const isMultiframe = useSelector(selectors.getIsMultiframe);
const isJustLoaded = useOnViewerLoaded(...); // write this yourself
useEffect(() => {
if (isJustLoaded && isMultiframe)
dispatch(actions.setCine({ isPlaying: true });
}, [isJustLoaded, isMultiframe]}
}
Dear PoyangLiu, thank you so much for your kind assistance!!
I understand your instructions a little bit. I'm into radiology and not into deep programming which I think requires here. I can do some basic programming, however, here I don't know which files to modify and what to write inside useOnViewerLoaded :).
I guess I will wait until this gets implemented.
I used to use version 1 which had this feature implemented and was very useful but version 1 had some bugs which now no one is going to support so I jumped into newer version but now finding some old features are missing or are not working.
Again, I truly appreciate your time into looking into this issue.
Best regards, Ric
HI Ric,
I'd call the useAutoPlayCine
logic in Viewer.js
. As for useOnViewerLoaded
, what I meant was that it should detect the redux state when first initialized. So you want to detect the rising edge when the viewportSpecificData
goes from null/undefined
to defined
. After that, you don't want to check isMultiframe
anymore. Otherwise, every time you click on the viewport that contains multiframe, it will always starts playing cine even if you've turned it off previously. This is super annoying.
The entire feature also needs to be associated with the user preferences (which is also in redux store).
As you mentioned, you need some dev background to do this.
Truly appreciate PoyangLiu, thank you for you kind assistance again!!
Looking at your earlier post I got little excited in programming and start Googling for Redux and found this extension for Google. This was very cool. I could see so much more code happeing behind the scene now :). Thank you for sharing the screen shot!!
I will play little bit with the code now that you have given me so much helpful guidance. I hope that I should be able to make this work for me.
Best regards, Ric
Dear PoyangLiu,
The reason I was desperately trying to find the solution is because I go thru around 60 echo studies daily. Each study has around 50-60 cine series in it. This means I have to click 50 series * 50 studies = 2,500 clicks daily just to play the images. This is way too many clicks. In version 1, it used to autoplay each cine series as soon as it comes to viewport, meaning zero click.
I was hoping that this feature shouldn't be that hard for a developer to implement saving us poor fellows 2,500+ clicks a day :)
Best regards, Ric
Dear PoyangLiu,
Do you think you could guide me bit more as clicking every series to play is bit overwhelming.
I was wondering how to call useAutoPlayCine routing in Viewer.js. In other words, which routing would call useAutoPlayCine etc.
Thank you!
@richsmith123, my code snippet from the previous comments uses a "react hook". This kind of hook is used in functional component. It is meant to be pseudo-code.
The same logic, however, can be applied to Viewer.js in OHIF code-base that uses the classical class component. You'll have to change the code, obviously.
I'd suggest you forget about the isJustLoaded
. Look at the following two files:
The steps are roughly this:
- In
ConnectedViewer.js
, access the redux state and determineisMultiframe
, add tomapStateToProps
- In
ConnectedViewer.js
, add a method (saystartCine
) tomapDispatchToProps
, which will dispatch action to start cine - In
Viewer.js
, you can now accessisMultiframe
andstartCine
inprops
- In
Viewer.js: componentDidMount
, callstartCine
ifisMultiframe
is true
You can find example on how to access state
and how to dispatch
all over the codebase, including the ConnectedViewer
file itself. If you don't know what I'm talking about, you'll have to read-up on react redux.
That's the gist of it.
Dear PoyangLiu,
Truly appreciate your help in guiding me, thank you!!
Best regards,
will this solution work for displaying the DICOM image (not a study) in OHIF using the JSON supplied via the '?url=' query parameter? can you help me with the snippet of the code for the above mentioned solution. I am new to react. @PoyangLiu
Unfortunately, this is not currently a priority and is still in the planning stage.
@richsmith123 confirmed that autoPlayCine in default.js works in master