vanvalenlab / kiosk-frontend

DeepCell web application built using NodeJS, Express, React, and Webpack.
Other
1 stars 0 forks source link

Add more options for Polaris jobs #182

Closed tddough98 closed 2 years ago

tddough98 commented 2 years ago

This PR introduces two new components MesmerForm and PolarisForm that contain workflow specific forms so that those jobs can be parameterized. The behavior for mesmer is unchanged, which polaris can now pick what segmentation model to use and which channels to use segmentation.

Each Form component updates the jobForm object in the Predict component. We now send the jobForm object to the /predict route, which unpacks the form to send to the consumer. As we expand the supported workflows and the contents of the jobForm varies more, we'll need to revisit how the route handles the jobForm contents.

I've also refactored the ChannelForm to simplify the state for selected channels. Previously, there were four collaborating variables that tracked the selected channels including:

These variables had to be transformed between each other with complex expression like Object.keys(channels).reduce((r, c) => Object.assign(r, { [channels[c]]: parseInt((r[channels[c]] || '').concat(c)) }), {}) and requiredChannels.map(c => channelValues[targetChannels[c]]).

I've refactored these variables into just requiredChannels ['nuclei', 'cytoplasm'] and selectedChannels [0, 1] which records which channel index should be used for each required channel. The selectedChannels are more similar to the data submitted to the api and is transformed with a simple expression selectedChannels.join(',') to yield 0,1. I've also moved ['red', 'green', 'blue'] to an internal detail of the ChannelDropdown component as it is only used in display text.

elaubsch commented 2 years ago

With the way the Polaris application is set up right now, it can't handle cytoplasm and nuclear segmentation for cell culture images. Could we make "None" an option for the channel form dropdown?

tddough98 commented 2 years ago

We submit selected channels as a comma separated list of channels indices. Something like 2,0 for mesmer to say the third channel is the nuclei and the first channel is the cytoplasm or0,2,1 for polaris to say the first channel is spots, the second is cytoplasm and the third is nuclei.

Would it work to leave out the number when we don't have a channel? So submitting 0,, to the polaris consumer means the first channel is spots and are there no nuclei or cytoplasm channels.

tddough98 commented 2 years ago

I've added a boolean required prop to the ChannelDropdown component that adds a None option to the select menu when true. Both MesmerForm and PolarisForm now have to specify which of their channels are required or not, so I've renamed requiredChannels to channels and changed requiredChannels to a list of booleans.

Here's what the form now looks like.

Screen Shot 2022-02-14 at 10 57 47 AM