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

Feat/na 123 #508

Closed
wants to merge 106 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
1be4be1
refactor: move volume rendering shaders to module
seankmartin Sep 28, 2023
e77e97d
feat: simple maximum projection shader
seankmartin Sep 28, 2023
6568d61
feat: volume render shader UI control
seankmartin Sep 28, 2023
60fbb5a
temp: hacky way to update shader on UI change
seankmartin Sep 28, 2023
b69be5c
chore: formatting via clang-format
seankmartin Sep 28, 2023
00f9d68
feat: visualise chunk number in vr
seankmartin Sep 29, 2023
c3bd92c
fix: small MPI fix
seankmartin Sep 29, 2023
7a5e1ed
feat: update MPI shader to have userMain
seankmartin Sep 29, 2023
0235a31
chore: refactor shaders to glsl_SHADER_NAME
seankmartin Oct 2, 2023
a19e29d
feat: update shader when text change
seankmartin Oct 2, 2023
8ac2007
feat: update shader on selection change
seankmartin Oct 2, 2023
68c89a9
bugfix: correct key for shader selection restore
seankmartin Oct 2, 2023
cf6a9b5
chore: remove unused comment
seankmartin Oct 2, 2023
6756a6f
chore: clang-format changed files
seankmartin Oct 2, 2023
fa844c6
chore: clearer naming of volume rendering mode
seankmartin Oct 3, 2023
8283480
feat(Python): allow control of VR mode
seankmartin Oct 3, 2023
123fcdb
Merge branch 'master' into feat/change-vr-modes
seankmartin Oct 10, 2023
1028b72
feat(Python): control volume rendering mode
seankmartin Oct 10, 2023
7e00179
feat: change VR bool to Enum
seankmartin Oct 11, 2023
68c5908
fix: remove unused code
seankmartin Oct 11, 2023
11d4422
refactor: remove VR glsl and rename shader modes
seankmartin Oct 11, 2023
167a37c
refactor: rename volume rendering mode image layer
seankmartin Oct 11, 2023
f11c519
fix(Python): match JSON key with VR mode tool
seankmartin Oct 11, 2023
2b6c426
feat: replace chunk debug VR shader with setting
seankmartin Oct 12, 2023
f5f2a68
feat: shorten VR names for display ease
seankmartin Oct 12, 2023
443e406
chore: clang-format files
seankmartin Oct 18, 2023
a04fa5c
feat: in progress with TF widget
seankmartin Oct 20, 2023
84fc55d
feat: visible transfer function
seankmartin Oct 23, 2023
90c5c89
temp: texture fetch scaffolding
seankmartin Oct 23, 2023
fc1cf6a
temp: example shader (pulls incorrect texture)
seankmartin Oct 23, 2023
629603a
temp: example binding texture inside VR
seankmartin Oct 23, 2023
e3c6a71
fix: symbol
seankmartin Oct 23, 2023
63cb656
temp: small tf change
seankmartin Oct 23, 2023
b497867
feat: rename "direct" VR to "on"
seankmartin Oct 23, 2023
d61000f
In progress with TF idea
seankmartin Oct 30, 2023
eb995ed
feat: skeleton of transfer function code
seankmartin Nov 1, 2023
edf07e7
feat: in progress with transfer functions
seankmartin Nov 1, 2023
46df0f5
fix: correct quad positions in TF
seankmartin Nov 1, 2023
37acb0e
fix: control point lerp
seankmartin Nov 1, 2023
8f8a76d
fix: import path in volume_render_layer.ts and
seankmartin Nov 6, 2023
8262f1e
fix: image user layer import
seankmartin Nov 6, 2023
7b4d8d8
refactor: rename volume rendering mode
seankmartin Nov 6, 2023
5f9c7a8
Merge branch 'feat/change-vr-modes' into develop
seankmartin Nov 9, 2023
b2c9276
chore: format after merge
seankmartin Nov 9, 2023
7855fbe
feat: front to back compositing
seankmartin Nov 9, 2023
b85f127
temp: sampling ratio along rays
seankmartin Nov 9, 2023
6b0e2eb
Merge branch 'feat/transfer-function-widget' into develop
seankmartin Nov 9, 2023
88fed6f
progress: track control points from shader widget
seankmartin Nov 9, 2023
edcdcf2
progress: continue with TFs
seankmartin Nov 10, 2023
5eb67c8
fix: progress fixing VR
seankmartin Nov 10, 2023
0ad1103
feat: revamp interaction between VR on and max
seankmartin Nov 10, 2023
e6e3ef3
feat: able to pass control points around
seankmartin Nov 10, 2023
8919a75
fix: avoid error on shader
seankmartin Nov 10, 2023
43c602d
feat: allow for multiple transfer function textures
seankmartin Nov 10, 2023
4cc2a43
fix: compilation errors with TF shader
seankmartin Nov 10, 2023
ff88a01
feat: working TF but slow
seankmartin Nov 10, 2023
36f4930
feat: change lerping tf behavior
seankmartin Nov 10, 2023
38967b1
feat: render points of control on TF
seankmartin Nov 10, 2023
0fc6aee
temp: in progress with showing control point
seankmartin Nov 13, 2023
2170274
temp: in progress with show point
seankmartin Nov 13, 2023
56db3fd
feat: working control point circle shader
seankmartin Nov 13, 2023
859fdd7
temp: in progress with lines between ctrl poitns
seankmartin Nov 13, 2023
cb29172
feat: interpolate a line between control points
seankmartin Nov 13, 2023
69246a2
feat: ability to grab control points
seankmartin Nov 13, 2023
dee764d
feat: move around control points
seankmartin Nov 13, 2023
8dfdd2f
feat: ability to delete control points
seankmartin Nov 13, 2023
2b03497
feat: transfer function color pick
seankmartin Nov 14, 2023
bbc1a60
feat: working version of set color
seankmartin Nov 14, 2023
4a4fcca
feat: control modify pick
seankmartin Nov 14, 2023
7e72add
refactor: more private tfs
seankmartin Nov 14, 2023
a674e46
feat: stop deselect on leave for now
seankmartin Nov 14, 2023
fe8b4f6
feat: update default shader code
seankmartin Nov 14, 2023
cb79d1a
feat: improve opacity handling in tf
seankmartin Nov 14, 2023
e7c9d2d
fix: colorPicker annoying interactions
seankmartin Nov 14, 2023
571cdfd
fix: wireframe mode interaction
seankmartin Nov 14, 2023
871f256
feat: support multiple data types in TF
seankmartin Nov 14, 2023
2063b2a
refactor: improve TF grid size handling
seankmartin Nov 14, 2023
3336264
fix: modifiable TF gridsize
seankmartin Nov 14, 2023
0d639df
feat: initial transfer function range
seankmartin Nov 15, 2023
c9322d0
feat: shader can control default TF points
seankmartin Nov 15, 2023
bc8559c
fix: better tf json state
seankmartin Nov 15, 2023
7f578d7
fix: restore control point state
seankmartin Nov 16, 2023
d837901
fix: keep color in TF
seankmartin Nov 16, 2023
7d0731f
temp tag for deployment
seankmartin Nov 16, 2023
05897c2
temp: fix tag
seankmartin Nov 16, 2023
c45a9e8
feat: modify sampling ratio to be a uniform
seankmartin Nov 17, 2023
37d5563
temp: update tag
seankmartin Nov 20, 2023
76e8285
fix: max projection mode with TFs
seankmartin Nov 20, 2023
19f46de
temp: update tag to 21
seankmartin Nov 21, 2023
b465bad
Update README.md
SimaoBolota-MetaCell Nov 21, 2023
2961389
Update README.md
seankmartin Nov 22, 2023
2ecb155
Update README.md
seankmartin Nov 22, 2023
415454e
Merge pull request #5 from MetaCell/readme-update
seankmartin Nov 22, 2023
2d8441f
Merge branch 'master' into develop
seankmartin Nov 22, 2023
25f08f7
feat: add range of TF to UI
seankmartin Dec 1, 2023
f5102ae
Merge pull request #8 from MetaCell/feat/NA-112
seankmartin Dec 1, 2023
e39f276
chore: clang-format changed files for TF
seankmartin Dec 1, 2023
b36dca6
temp: december tag
seankmartin Dec 1, 2023
edbdb76
temp: update tag
seankmartin Dec 1, 2023
2f0b309
fix: correctly pass state updates
seankmartin Dec 11, 2023
de31706
fix: correct line placement for TF start
seankmartin Dec 11, 2023
2144073
Merge remote-tracking branch 'upstream/master' into feat/NA-143
seankmartin Dec 11, 2023
29a6795
Merge pull request #9 from MetaCell/feat/NA-143
seankmartin Dec 11, 2023
dc48b8c
feat: update color state in TF
seankmartin Dec 12, 2023
e9616d6
Merge branch 'feat/NA-143' into develop
seankmartin Dec 12, 2023
f746c3c
feat: working tool map for TF
seankmartin Dec 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,19 @@ node.js is required to build the viewer.

`npm test -- --pattern='src/neuroglancer/util/uint64*'`

6. See [package.json](package.json) for other commands available.
6. To run python scripts for the local server:

Run

`npm run build-python`

`pip install .`

from the neuroglancer folder.
Now python scripts can run for the local server.


7. See [package.json](package.json) for other commands available.

# Creating a dependent project

Expand Down
1 change: 1 addition & 0 deletions python/neuroglancer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
BlendTool, # noqa: F401
OpacityTool, # noqa: F401
VolumeRenderingDepthSamplesTool, # noqa: F401
VolumeRenderingModeTool, # noqa: F401
CrossSectionRenderScaleTool, # noqa: F401
SelectedAlphaTool, # noqa: F401
NotSelectedAlphaTool, # noqa: F401
Expand Down
9 changes: 9 additions & 0 deletions python/neuroglancer/viewer_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ class VolumeRenderingDepthSamplesTool(Tool):
TOOL_TYPE = "volumeRenderingDepthSamples"


@export_tool
class VolumeRenderingModeTool(Tool):
__slots__ = ()
TOOL_TYPE = "volumeRenderingMode"


@export_tool
class CrossSectionRenderScaleTool(Tool):
__slots__ = ()
Expand Down Expand Up @@ -549,6 +555,9 @@ def __init__(self, *args, **kwargs):
cross_section_render_scale = crossSectionRenderScale = wrapped_property(
"crossSectionRenderScale", optional(float, 1)
)
volume_rendering_mode = volumeRenderingMode = wrapped_property(
"volumeRenderingMode", optional(str)
)

@staticmethod
def interpolate(a, b, t):
Expand Down
33 changes: 19 additions & 14 deletions src/neuroglancer/image_user_layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ import {MultiscaleVolumeChunkSource} from 'neuroglancer/sliceview/volume/fronten
import {defineImageLayerShader, getTrackableFragmentMain, ImageRenderLayer} from 'neuroglancer/sliceview/volume/image_renderlayer';
import {trackableAlphaValue} from 'neuroglancer/trackable_alpha';
import {trackableBlendModeValue} from 'neuroglancer/trackable_blend';
import {TrackableBoolean} from 'neuroglancer/trackable_boolean';
import {makeCachedDerivedWatchableValue, makeCachedLazyDerivedWatchableValue, registerNested, WatchableValue, WatchableValueInterface} from 'neuroglancer/trackable_value';
import {UserLayerWithAnnotationsMixin} from 'neuroglancer/ui/annotations';
import {setClipboard} from 'neuroglancer/util/clipboard';
import {Borrowed} from 'neuroglancer/util/disposable';
import {makeValueOrError} from 'neuroglancer/util/error';
import {verifyOptionalObjectProperty} from 'neuroglancer/util/json';
import {trackableShaderModeValue, VOLUME_RENDERING_MODES} from 'neuroglancer/volume_rendering/trackable_volume_rendering_mode';
import {getVolumeRenderingDepthSamplesBoundsLogScale, VOLUME_RENDERING_DEPTH_SAMPLES_DEFAULT_VALUE, VolumeRenderingRenderLayer} from 'neuroglancer/volume_rendering/volume_render_layer';
import {makeWatchableShaderError, ParameterizedShaderGetterResult} from 'neuroglancer/webgl/dynamic_shader';
import {setControlsInShader, ShaderControlsBuilderState, ShaderControlState} from 'neuroglancer/webgl/shader_ui_controls';
Expand All @@ -42,7 +42,6 @@ import {makeCopyButton} from 'neuroglancer/widget/copy_button';
import {DependentViewContext} from 'neuroglancer/widget/dependent_view_widget';
import {makeHelpButton} from 'neuroglancer/widget/help_button';
import {addLayerControlToOptionsTab, LayerControlDefinition, registerLayerControl} from 'neuroglancer/widget/layer_control';
import {checkboxLayerControl} from 'neuroglancer/widget/layer_control_checkbox';
import {enumLayerControl} from 'neuroglancer/widget/layer_control_enum';
import {rangeLayerControl} from 'neuroglancer/widget/layer_control_range';
import {makeMaximizeButton} from 'neuroglancer/widget/maximize_button';
Expand All @@ -57,8 +56,8 @@ const SHADER_JSON_KEY = 'shader';
const SHADER_CONTROLS_JSON_KEY = 'shaderControls';
const CROSS_SECTION_RENDER_SCALE_JSON_KEY = 'crossSectionRenderScale';
const CHANNEL_DIMENSIONS_JSON_KEY = 'channelDimensions';
const VOLUME_RENDERING_JSON_KEY = 'volumeRendering';
const VOLUME_RENDERING_DEPTH_SAMPLES_JSON_KEY = 'volumeRenderingDepthSamples';
const VOLUME_RENDERING_MODE_JSON_KEY = 'volumeRenderingMode';

export interface ImageLayerSelectionState extends UserLayerSelectionState {
value: any;
Expand Down Expand Up @@ -87,7 +86,7 @@ export class ImageUserLayer extends Base {
channelSpace = this.registerDisposer(makeCachedLazyDerivedWatchableValue(
channelCoordinateSpace => makeValueOrError(() => getChannelSpace(channelCoordinateSpace)),
this.channelCoordinateSpace));
volumeRendering = new TrackableBoolean(false, false);
volumeRenderingMode = trackableShaderModeValue();

shaderControlState = this.registerDisposer(new ShaderControlState(
this.fragmentMain,
Expand Down Expand Up @@ -127,9 +126,10 @@ export class ImageUserLayer extends Base {
this.opacity.changed.add(this.specificationChanged.dispatch);
this.fragmentMain.changed.add(this.specificationChanged.dispatch);
this.shaderControlState.changed.add(this.specificationChanged.dispatch);
this.shaderControlState.changed.add(() => {console.log("shaderControlState changed");});
this.sliceViewRenderScaleTarget.changed.add(this.specificationChanged.dispatch);
this.volumeRendering.changed.add(this.specificationChanged.dispatch);
this.volumeRenderingDepthSamplesTarget.changed.add(this.specificationChanged.dispatch);
this.volumeRenderingMode.changed.add(this.specificationChanged.dispatch);
this.tabs.add(
'rendering',
{label: 'Rendering', order: -100, getter: () => new RenderingOptionsTab(this)});
Expand Down Expand Up @@ -173,12 +173,13 @@ export class ImageUserLayer extends Base {
chunkResolutionHistogram: this.volumeRenderingChunkResolutionHistogram,
localPosition: this.localPosition,
channelCoordinateSpace: this.channelCoordinateSpace,
mode: this.volumeRenderingMode,
}));
context.registerDisposer(loadedSubsource.messages.addChild(volumeRenderLayer.messages));
context.registerDisposer(registerNested((context, volumeRendering) => {
if (!volumeRendering) return;
context.registerDisposer(registerNested((context, volumeRenderingMode) => {
if (volumeRenderingMode === VOLUME_RENDERING_MODES.OFF) return;
context.registerDisposer(this.addRenderLayer(volumeRenderLayer.addRef()));
}, this.volumeRendering));
}, this.volumeRenderingMode));
this.shaderError.changed.dispatch();
});
}
Expand All @@ -195,9 +196,11 @@ export class ImageUserLayer extends Base {
this.sliceViewRenderScaleTarget.restoreState(
specification[CROSS_SECTION_RENDER_SCALE_JSON_KEY]);
this.channelCoordinateSpace.restoreState(specification[CHANNEL_DIMENSIONS_JSON_KEY]);
this.volumeRendering.restoreState(specification[VOLUME_RENDERING_JSON_KEY]);
this.volumeRenderingDepthSamplesTarget.restoreState(
specification[VOLUME_RENDERING_DEPTH_SAMPLES_JSON_KEY]);
verifyOptionalObjectProperty(
specification, VOLUME_RENDERING_MODE_JSON_KEY,
mode => this.volumeRenderingMode.restoreState(mode));
}
toJSON() {
const x = super.toJSON();
Expand All @@ -207,8 +210,8 @@ export class ImageUserLayer extends Base {
x[SHADER_CONTROLS_JSON_KEY] = this.shaderControlState.toJSON();
x[CROSS_SECTION_RENDER_SCALE_JSON_KEY] = this.sliceViewRenderScaleTarget.toJSON();
x[CHANNEL_DIMENSIONS_JSON_KEY] = this.channelCoordinateSpace.toJSON();
x[VOLUME_RENDERING_JSON_KEY] = this.volumeRendering.toJSON();
x[VOLUME_RENDERING_DEPTH_SAMPLES_JSON_KEY] = this.volumeRenderingDepthSamplesTarget.toJSON();
x[VOLUME_RENDERING_MODE_JSON_KEY] = this.volumeRenderingMode.toJSON();
return x;
}

Expand Down Expand Up @@ -318,20 +321,22 @@ const LAYER_CONTROLS: LayerControlDefinition<ImageUserLayer>[] = [
},
{
label: 'Volume rendering (experimental)',
toolJson: VOLUME_RENDERING_JSON_KEY,
...checkboxLayerControl(layer => layer.volumeRendering),
toolJson: VOLUME_RENDERING_MODE_JSON_KEY,
...enumLayerControl(layer => layer.volumeRenderingMode),
},
{
label: 'Resolution (3D)',
toolJson: VOLUME_RENDERING_DEPTH_SAMPLES_JSON_KEY,
isValid: layer => layer.volumeRendering,
isValid: layer => makeCachedDerivedWatchableValue(
volumeRendering => (volumeRendering !== VOLUME_RENDERING_MODES.OFF),
[layer.volumeRenderingMode]),
...renderScaleLayerControl(
layer => ({
histogram: layer.volumeRenderingChunkResolutionHistogram,
target: layer.volumeRenderingDepthSamplesTarget
}),
VolumeRenderingRenderScaleWidget,
)
),
},
];

Expand Down
4 changes: 3 additions & 1 deletion src/neuroglancer/layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ const SOURCE_JSON_KEY = 'source';
const TRANSFORM_JSON_KEY = 'transform';
const PICK_JSON_KEY = 'pick';

const METACELL_TAG = ' 011223'

export interface UserLayerSelectionState {
generation: number;

Expand Down Expand Up @@ -269,7 +271,7 @@ export class UserLayer extends RefCounted {
this.dataSourcesChanged.add(() => this.updateDataSubsourceActivations());
this.messages.changed.add(this.layersChanged.dispatch);
this.tabs.add('source', {
label: 'Source',
label: `Source ${METACELL_TAG}`,
order: -100,
getter: () => new LayerDataSourcesTab(this),
});
Expand Down
10 changes: 9 additions & 1 deletion src/neuroglancer/sliceview/volume/image_renderlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,14 @@ import {ShaderBuilder, ShaderProgram} from 'neuroglancer/webgl/shader';
import {addControlsToBuilder, getFallbackBuilderState, parseShaderUiControls, setControlsInShader, ShaderControlsBuilderState, ShaderControlState} from 'neuroglancer/webgl/shader_ui_controls';

const DEFAULT_FRAGMENT_MAIN = `#uicontrol invlerp normalized
#uicontrol transferFunction colormap
void main() {
emitGrayscale(normalized());
if (!VOLUME_RENDERING) {
emitGrayscale(normalized());
}
else {
emitRGBA(colormap());
}
}
`;

Expand All @@ -46,6 +52,8 @@ export function defineImageLayerShader(
builder: ShaderBuilder, shaderBuilderState: ShaderControlsBuilderState) {
builder.addFragmentCode(`
#define VOLUME_RENDERING false
#define MAX_PROJECTION false
float maxIntensity = 0.0;

void emitRGBA(vec4 rgba) {
emit(vec4(rgba.rgb, rgba.a * uOpacity));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {TrackableEnum} from 'neuroglancer/util/trackable_enum';

export enum VOLUME_RENDERING_MODES {
OFF = 0,
ON = 1,
MAX = 2
}

export type TrackableVolumeRenderingModeValue = TrackableEnum<VOLUME_RENDERING_MODES>;

export function trackableShaderModeValue(initialValue = VOLUME_RENDERING_MODES.OFF) {
return new TrackableEnum(VOLUME_RENDERING_MODES, initialValue);
}
Loading
Loading