Skip to content

Commit

Permalink
GUI HCS Viewer: view settings (#3757)
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksandrGorodetskii authored Nov 4, 2024
1 parent f125a8e commit 4b137c3
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 47 deletions.
112 changes: 68 additions & 44 deletions client/src/components/special/hcs-image/hcs-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ class HcsImage extends React.PureComponent {
return (this.hcsInfo.sequences || []).map(s => s);
}

@computed
get viewSettings () {
return this.hcsInfo?.viewSettings || {
video: true,
analysis: true,
plate: true,
well: true,
timeseries: true
};
}

get selectedSequences () {
const {selectedSequenceTimePoints = []} = this.state;
const selectedSequencesIds = [
Expand Down Expand Up @@ -731,7 +742,9 @@ class HcsImage extends React.PureComponent {
) {
return null;
}
const analysisAvailable = this.hcsAnalysis && this.hcsAnalysis.available;
const analysisAvailable = this.hcsAnalysis &&
this.hcsAnalysis.available &&
this.viewSettings.analysis;
const selectedImage = this.selectedWellFields[0];
if (!showConfiguration) {
return (
Expand All @@ -749,14 +762,16 @@ class HcsImage extends React.PureComponent {
</Button>
)
}
<VideoButton
className={styles.action}
videoSource={this.hcsVideoSource}
available={
(this.selectedSequence && this.selectedSequence.timeSeries.length > 1) ||
(selectedImage && selectedImage.depth > 1)
}
/>
{this.viewSettings.video ? (
<VideoButton
className={styles.action}
videoSource={this.hcsVideoSource}
available={
(this.selectedSequence && this.selectedSequence.timeSeries.length > 1) ||
(selectedImage && selectedImage.depth > 1)
}
/>
) : null}
<HCSDownloadButton
size="small"
className={styles.action}
Expand Down Expand Up @@ -1004,6 +1019,7 @@ class HcsImage extends React.PureComponent {
selectedWells = [],
selectedFields = []
} = this.state;
const viewSettings = this.viewSettings;
const sequenceInfo = this.selectedSequence;
const selectedWell = this.selectedWell;
const selectedImage = this.selectedWellFields[0];
Expand All @@ -1022,48 +1038,56 @@ class HcsImage extends React.PureComponent {
'cp-content-panel'
)
}
style={{width: 'fit-content'}}
>
<HcsCellSelector
className={styles.selectorContainer}
title="Plate"
cells={sequenceInfo.wells}
selected={selectedWells}
onChange={this.changeWells}
width={HcsCellSelector.widthCorrection(plateWidth, sequenceInfo.wells)}
height={HcsCellSelector.heightCorrection(plateHeight, sequenceInfo.wells)}
showRulers
searchPlaceholder="Search wells"
showElementHint
/>
<HcsCellSelector
className={styles.selectorContainer}
title={selectedWell.id}
cells={selectedWell.images}
selected={selectedFields}
onChange={this.changeWellImages}
gridMode="CROSS"
width={
HcsCellSelector.widthCorrection(selectedWell.width, selectedWell.images)
}
height={
HcsCellSelector.heightCorrection(selectedWell.height, selectedWell.images)
}
scaleToROI
radius={selectedWell.radius}
/>
<HcsSequenceSelector
sequences={this.sequences}
selection={selectedSequenceTimePoints}
onChange={this.onChangeSequenceTimePoints}
multiple
style={{padding: 5}}
/>
{viewSettings.plate ? (
<HcsCellSelector
className={styles.selectorContainer}
title="Plate"
cells={sequenceInfo.wells}
selected={selectedWells}
onChange={this.changeWells}
width={HcsCellSelector.widthCorrection(plateWidth, sequenceInfo.wells)}
height={HcsCellSelector.heightCorrection(plateHeight, sequenceInfo.wells)}
showRulers
searchPlaceholder="Search wells"
showElementHint
/>
) : null}
{viewSettings.well ? (
<HcsCellSelector
className={styles.selectorContainer}
title={selectedWell.id}
cells={selectedWell.images}
selected={selectedFields}
onChange={this.changeWellImages}
gridMode="CROSS"
width={
HcsCellSelector.widthCorrection(selectedWell.width, selectedWell.images)
}
height={
HcsCellSelector.heightCorrection(selectedWell.height, selectedWell.images)
}
scaleToROI
radius={selectedWell.radius}
/>
) : null}
{viewSettings.timeseries ? (
<HcsSequenceSelector
sequences={this.sequences}
selection={selectedSequenceTimePoints}
onChange={this.onChangeSequenceTimePoints}
multiple
style={{padding: 5, maxWidth: 300}}
/>
) : null}
<HcsZPositionSelector
image={selectedImage}
selection={selectedZCoordinates}
mergeZPlanes={mergeZPlanes}
onChange={this.onChangeZCoordinates}
multiple
style={{maxWidth: 300}}
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function buildZPositionsArray (max, zSize, zUnit) {
function HcsZPositionSelector (props) {
const {
className,
style,
image,
selection: rawSelection = [0],
onChange,
Expand Down Expand Up @@ -107,6 +108,7 @@ function HcsZPositionSelector (props) {
className,
styles.container
)}
style={style}
>
<div
className={styles.title}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {createObjectStorageWrapper} from '../../../../utils/object-storage';
* @property {number} width
* @property {number} height
* @property {Object} timeSeriesDetails
* @property {Object} viewSettings
*/

class HCSInfo {
Expand All @@ -42,7 +43,8 @@ class HCSInfo {
sourceDirectory,
width,
height,
timeSeriesDetails = {}
timeSeriesDetails = {},
viewSettings = {}
} = options;
const sequences = Object.keys(timeSeriesDetails);
if (sequences.length === 0) {
Expand Down Expand Up @@ -80,6 +82,17 @@ class HCSInfo {
* @type {number}
*/
this.height = Number.isNaN(Number(height)) ? 0 : Number(height);
/**
* View settings (enable/disable functionality)
* @type {Object}
*/
this.viewSettings = {
video: `${viewSettings.video}` !== 'false',
analysis: `${viewSettings.analysis}` !== 'false',
plate: `${viewSettings['plate_layout']}` !== 'false',
well: `${viewSettings['well_layout']}` !== 'false',
timeseries: `${viewSettings['timeseries_layout']}` !== 'false'
};
/**
* Sequences info
* @type {HCSImageSequence[]}
Expand Down Expand Up @@ -167,7 +180,8 @@ class HCSInfo {
sourceDir: sourceDirectory,
plate_height: height,
plate_width: width,
time_series_details: timeSeriesDetails = {}
time_series_details: timeSeriesDetails = {},
view_settings: viewSettings = {}
} = json;
resolve(
new HCSInfo({
Expand All @@ -177,7 +191,8 @@ class HCSInfo {
width,
height,
objectStorage,
timeSeriesDetails
timeSeriesDetails,
viewSettings
})
);
} catch (e) {
Expand Down

0 comments on commit 4b137c3

Please sign in to comment.