diff --git a/GoVizzy/GoVizzy.ipynb b/GoVizzy/GoVizzy.ipynb index 1c51a62..ceee366 100644 --- a/GoVizzy/GoVizzy.ipynb +++ b/GoVizzy/GoVizzy.ipynb @@ -2,19 +2,23 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, - "id": "09026008-ce47-49d7-9fca-4b7c123022d1", "metadata": {}, "outputs": [ { - "name": "stderr", - "output_type": "stream", - "text": [ - "/mnt/d/Documents/GoVizzy/s24-slice-n-dice/.venv/lib/python3.11/site-packages/pandas/core/arrays/masked.py:60: UserWarning: Pandas requires version '1.3.6' or newer of 'bottleneck' (version '1.3.5' currently installed).\n", - " from pandas.core import (\n" - ] + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "fe1d0a81c0c74a07be2994082d69065b", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "AppLayout(children=(HBox(children=(Button(button_style='danger', description='[X]', layout=Layout(margin='0 0 …" + ] + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [ @@ -29,36 +33,19 @@ }, { "cell_type": "code", - - "execution_count": 2, - "id": "ef52d91c-9d81-41db-953b-78f7ef718f24", + "execution_count": 5, + "id": "67faad66-2beb-4746-b0a4-21689ddc78d3", "metadata": {}, "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Loading data/rhopol.cube ...\n", - "Done.\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/mnt/d/Documents/GoVizzy/s24-slice-n-dice/.venv/lib/python3.11/site-packages/ipyvolume/serialize.py:102: RuntimeWarning: invalid value encountered in cast\n", - " subdata[..., i] = ((gradient[i][zindex] / 2.0 + 0.5) * 255).astype(np.uint8)\n" - ] - }, { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "5b191f581bee4041aab75cf105afc006", + "model_id": "e4b35176cd3c4be5bd4d2cb94b0437f8", "version_major": 2, "version_minor": 0 }, "text/plain": [ - "Container(children=[VBox(children=(HBox(children=(Label(value='levels:'), FloatSlider(value=0.1, max=1.0, step…" + "HBox(children=(Text(value='', description='File Name:'), Button(description='Submit', style=ButtonStyle())))" ] }, "metadata": {}, @@ -66,71 +53,78 @@ } ], "source": [ - "cube: Cube = Cube()\n", - "cube.load_cube(\"data/rhopol.cube\")\n", - "visualizer = plotting.Visualizer(cube)\n", - "visualizer.display_cell()" - + "\n", + "%run Main.py\n" ] }, { "cell_type": "code", - - "execution_count": null, - "id": "8b9789df", - + "execution_count": 8, + "id": "ef52d91c-9d81-41db-953b-78f7ef718f24", "metadata": {}, "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Loading data/rhopol.cube ...\n", + "Done.\n" + ] + }, { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "8016bbc0bdde451eaf66d4fc1d11912b", + "model_id": "db7b576af62c48a294254ecdc19f7c3b", "version_major": 2, "version_minor": 0 }, "text/plain": [ - "AppLayout(children=(HBox(children=(Button(button_style='danger', description='[X]', layout=Layout(margin='0 0 …" + "Container(children=[VBox(children=(HBox(children=(Label(value='levels:'), FloatSlider(value=0.03, max=1.0, ste…" ] }, "metadata": {}, - "output_type": "execute_result" + "output_type": "display_data" } ], "source": [ - "form" + "# Load Cube File\n", + "cube: Cube = Cube()\n", + "cube.load_cube(\"data/rhopol.cube\")\n", + "visualizer = plotting.Visualizer(cube)\n", + "# Display Cube File\n", + "visualizer.display_cell()" ] }, { "cell_type": "code", - "execution_count": null, - "id": "67faad66-2beb-4746-b0a4-21689ddc78d3", + "execution_count": 6, + "id": "863d988e-36c3-463b-9b3f-d68e27ceb757", "metadata": {}, "outputs": [ - { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "4ff5fd806ff5473890d8b2b6b532270e", + "model_id": "b7c37980c359447188ef4fb14cece17b", "version_major": 2, "version_minor": 0 }, "text/plain": [ - "HBox(children=(Text(value='', description='File Name:'), Button(description='Submit', style=ButtonStyle())))" + "Box(children=(Box(children=(Label(value='Path to .cube file'), Textarea(value='')), layout=Layout(display='fle…" ] }, + "execution_count": 6, "metadata": {}, - "output_type": "display_data" + "output_type": "execute_result" } ], "source": [ - "\n", - "%run Main.py\n" + "form" ] }, { "cell_type": "code", "execution_count": null, - "id": "863d988e-36c3-463b-9b3f-d68e27ceb757", + "id": "2cc4ec86-2666-442f-a30b-7727d2a2ad9a", "metadata": {}, "outputs": [], "source": [] @@ -152,9 +146,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - - "version": "3.11.5" - + "version": "3.12.2" } }, "nbformat": 4, diff --git a/GoVizzy/GoVizzy/plotting.py b/GoVizzy/GoVizzy/plotting.py index dd958c4..eaaad88 100644 --- a/GoVizzy/GoVizzy/plotting.py +++ b/GoVizzy/GoVizzy/plotting.py @@ -1,4 +1,5 @@ import os +from widgets import color from cube_viskit import Cube import ipywidgets as widgets import ipyvolume as ipv @@ -95,5 +96,7 @@ def display_cell(self): """ cube = self.cube ipv.figure() - ipv.pylab.volshow(cube.data3D) + transfer = ipv.pylab.transfer_function(level=[0.03, 0.5, 0.47], opacity=[0.05, 0.09, 0.1], level_width=0.1, controls=True) + ipv.style.background_color(color.value) + ipv.pylab.volshow(cube.data3D, ambient_coefficient=0.8, lighting=True, tf=transfer, controls=True) ipv.show() \ No newline at end of file diff --git a/GoVizzy/UI/DisplayUI.py b/GoVizzy/UI/DisplayUI.py index dd30cdb..8342428 100644 --- a/GoVizzy/UI/DisplayUI.py +++ b/GoVizzy/UI/DisplayUI.py @@ -2,7 +2,7 @@ from ipywidgets import Dropdown, VBox, HBox, Output, ColorPicker, AppLayout, Layout, Label import ipyvolume as ipv import matplotlib.pyplot as plt -import UI.plotting +import GoVizzy.plotting # Define globals selected_option = 'Volumetric' @@ -87,15 +87,17 @@ def display_cell_data(cube): # Function to display cell data directly in the additional widget box with additional_box: additional_box.clear_output(wait=True) - visualizer = UI.plotting.Visualizer(cube) + visualizer = GoVizzy.plotting.Visualizer(cube) visualizer.display_cell_data() def display_ipyvolume_plot(cube): - data3D = cube.data3D - ipv.figure() - ipv.pylab.volshow(data3D) + #data3D = cube.data3D + #ipv.figure() + #ipv.pylab.volshow(data3D) with large_box: - ipv.show() + #ipv.show() + visualizer = GoVizzy.plotting.Visualizer(cube) + visualizer.display_cell() def display_app(large_box, additional_box):