Remote controlling#
DataLab may be controlled remotely using the XML-RPC protocol which is natively supported by Python (and many other languages). Remote controlling allows to access DataLab main features from a separate process.
Note
If you are looking for a lighweight alternative solution to remote control DataLab (i.e. without having to install the whole DataLab package and its dependencies on your environment), please have a look at the DataLab Simple Client package (pip install cdlclient).
From an IDE#
DataLab may be controlled remotely from an IDE (e.g. Spyder or any other
IDE, or even a Jupyter Notebook) that runs a Python script. It allows to
connect to a running DataLab instance, adds a signal and an image, and then
runs calculations. This feature is exposed by the RemoteProxy class that
is provided in module cdl.proxy
.
From a third-party application#
DataLab may also be controlled remotely from a third-party application, for the same purpose.
If the third-party application is written in Python 3, it may directly use the RemoteProxy class as mentioned above. From another language, it is also achievable, but it requires to implement a XML-RPC client in this language using the same methods of proxy server as in the RemoteProxy class.
Data (signals and images) may also be exchanged between DataLab and the remote client application, in both directions.
The remote client application may be written in any language that supports XML-RPC. For example, it is possible to write a remote client application in Python, Java, C++, C#, etc. The remote client application may be a graphical application or a command line application.
The remote client application may be run on the same computer as DataLab or on a different computer. In the latter case, the remote client application must know the IP address of the computer running DataLab.
The remote client application may be run before or after DataLab. In the latter case, the remote client application must try to connect to DataLab until it succeeds.
Supported features#
Supported features are the following:
Switch to signal or image panel
Remove all signals and images
Save current session to a HDF5 file
Open HDF5 files into current session
Browse HDF5 file
Open a signal or an image from file
Add a signal
Add an image
Get object list
Run calculation with parameters
Note
The signal and image objects are described on this section: Internal data model.
Some examples are provided to help implementing such a communication between your application and DataLab:
See module:
cdl.tests.remoteclient_app
See module:
cdl.tests.remoteclient_unit
Examples#
When using Python 3, you may directly use the RemoteProxy class as in examples cited above or below.
Here is an example in Python 3 of a script that connects to a running DataLab instance, adds a signal and an image, and then runs calculations (the cell structure of the script make it convenient to be used in Spyder IDE):
"""
Example of remote control of DataLab current session,
from a Python script running outside DataLab (e.g. in Spyder)
Created on Fri May 12 12:28:56 2023
@author: p.raybaut
"""
# %% Importing necessary modules
# NumPy for numerical array computations:
import numpy as np
# DataLab remote control client:
from cdl.proxy import RemoteProxy
# %% Connecting to DataLab current session
proxy = RemoteProxy()
# %% Executing commands in DataLab (...)
z = np.random.rand(20, 20)
proxy.add_image("toto", z)
# %% Executing commands in DataLab (...)
proxy.toggle_auto_refresh(False) # Turning off auto-refresh
x = np.array([1.0, 2.0, 3.0])
y = np.array([4.0, 5.0, -1.0])
proxy.add_signal("toto", x, y)
# %% Executing commands in DataLab (...)
proxy.compute_derivative()
proxy.toggle_auto_refresh(True) # Turning on auto-refresh
# %% Executing commands in DataLab (...)
proxy.set_current_panel("image")
# %% Executing a lot of commands without refreshing DataLab
z = np.random.rand(400, 400)
proxy.add_image("foobar", z)
with proxy.context_no_refresh():
for _idx in range(100):
proxy.compute_fft()
Here is a Python 2.7 reimplementation of this class:
# Copyright (c) DataLab Platform Developers, BSD 3-Clause license, see LICENSE file.
"""
DataLab remote controlling class for Python 2.7
"""
import io
import os
import os.path as osp
import socket
import sys
import ConfigParser as cp
import numpy as np
from guidata.userconfig import get_config_dir
from xmlrpclib import Binary, ServerProxy
def array_to_rpcbinary(data):
"""Convert NumPy array to XML-RPC Binary object, with shape and dtype"""
dbytes = io.BytesIO()
np.save(dbytes, data, allow_pickle=False)
return Binary(dbytes.getvalue())
def get_cdl_xmlrpc_port():
"""Return DataLab current XML-RPC port"""
if sys.platform == "win32" and "HOME" in os.environ:
os.environ.pop("HOME") # Avoid getting old WinPython settings dir
fname = osp.join(get_config_dir(), ".DataLab", "DataLab.ini")
ini = cp.ConfigParser()
ini.read(fname)
try:
return ini.get("main", "rpc_server_port")
except (cp.NoSectionError, cp.NoOptionError):
raise ConnectionRefusedError("DataLab has not yet been executed")
class RemoteClient(object):
"""Object representing a proxy/client to DataLab XML-RPC server"""
def __init__(self):
self.port = None
self.serverproxy = None
def connect(self, port=None):
"""Connect to DataLab XML-RPC server"""
if port is None:
port = get_cdl_xmlrpc_port()
self.port = port
url = "http://127.0.0.1:" + port
self.serverproxy = ServerProxy(url, allow_none=True)
try:
self.get_version()
except socket.error:
raise ConnectionRefusedError("DataLab is currently not running")
def get_version(self):
"""Return DataLab version"""
return self.serverproxy.get_version()
def close_application(self):
"""Close DataLab application"""
self.serverproxy.close_application()
def raise_window(self):
"""Raise DataLab window"""
self.serverproxy.raise_window()
def get_current_panel(self):
"""Return current panel"""
return self.serverproxy.get_current_panel()
def set_current_panel(self, panel):
"""Switch to panel"""
self.serverproxy.set_current_panel(panel)
def reset_all(self):
"""Reset all application data"""
self.serverproxy.reset_all()
def toggle_auto_refresh(self, state):
"""Toggle auto refresh state"""
self.serverproxy.toggle_auto_refresh(state)
def toggle_show_titles(self, state):
"""Toggle show titles state"""
self.serverproxy.toggle_show_titles(state)
def save_to_h5_file(self, filename):
"""Save to a DataLab HDF5 file"""
self.serverproxy.save_to_h5_file(filename)
def open_h5_files(self, h5files, import_all, reset_all):
"""Open a DataLab HDF5 file or import from any other HDF5 file"""
self.serverproxy.open_h5_files(h5files, import_all, reset_all)
def import_h5_file(self, filename, reset_all):
"""Open DataLab HDF5 browser to Import HDF5 file"""
self.serverproxy.import_h5_file(filename, reset_all)
def load_from_files(self, filenames):
"""Open objects from files in current panel (signals/images)"""
self.serverproxy.load_from_files(filenames)
def add_signal(
self, title, xdata, ydata, xunit=None, yunit=None, xlabel=None, ylabel=None
):
"""Add signal data to DataLab"""
xbinary = array_to_rpcbinary(xdata)
ybinary = array_to_rpcbinary(ydata)
p = self.serverproxy
return p.add_signal(title, xbinary, ybinary, xunit, yunit, xlabel, ylabel)
def add_image(
self,
title,
data,
xunit=None,
yunit=None,
zunit=None,
xlabel=None,
ylabel=None,
zlabel=None,
):
"""Add image data to DataLab"""
zbinary = array_to_rpcbinary(data)
p = self.serverproxy
return p.add_image(title, zbinary, xunit, yunit, zunit, xlabel, ylabel, zlabel)
def get_object_titles(self, panel=None):
"""Get object (signal/image) list for current panel"""
return self.serverproxy.get_object_titles(panel)
def get_object(self, nb_id_title=None, panel=None):
"""Get object (signal/image) by number, id or title"""
return self.serverproxy.get_object(nb_id_title, panel)
def get_object_uuids(self, panel=None):
"""Get object (signal/image) list for current panel"""
return self.serverproxy.get_object_uuids(panel)
def test_remote_client():
"""DataLab Remote Client test"""
cdl = RemoteClient()
cdl.connect()
data = np.array([[3, 4, 5], [7, 8, 0]], dtype=np.uint16)
cdl.add_image("toto", data)
if __name__ == "__main__":
test_remote_client()
Connection dialog#
The DataLab package also provides a connection dialog that may be used
to connect to a running DataLab instance. It is exposed by the
cdl.widgets.connection.ConnectionDialog
class.
Example of use:
# Copyright (c) DataLab Platform Developers, BSD 3-Clause license, see LICENSE file.
"""
DataLab Remote client connection dialog example
"""
# guitest: show,skip
from guidata.qthelpers import qt_app_context
from qtpy import QtWidgets as QW
from cdl.proxy import RemoteProxy
from cdl.widgets.connection import ConnectionDialog
def test_dialog():
"""Test connection dialog"""
proxy = RemoteProxy(autoconnect=False)
with qt_app_context():
dlg = ConnectionDialog(proxy.connect)
if dlg.exec():
QW.QMessageBox.information(None, "Connection", "Successfully connected")
else:
QW.QMessageBox.critical(None, "Connection", "Connection failed")
if __name__ == "__main__":
test_dialog()
Public API: remote client#
- class cdl.core.remote.RemoteClient#
Object representing a proxy/client to DataLab XML-RPC server. This object is used to call DataLab functions from a Python script.
Examples
Here is a simple example of how to use RemoteClient in a Python script or in a Jupyter notebook:
>>> from cdl.core.remote import RemoteClient >>> proxy = RemoteClient() >>> proxy.connect() Connecting to DataLab XML-RPC server...OK (port: 28867) >>> proxy.get_version() '1.0.0' >>> proxy.add_signal("toto", np.array([1., 2., 3.]), np.array([4., 5., -1.])) True >>> proxy.get_object_titles() ['toto'] >>> proxy["toto"] <cdl.core.model.signal.SignalObj at 0x7f7f1c0b4a90> >>> proxy[1] <cdl.core.model.signal.SignalObj at 0x7f7f1c0b4a90> >>> proxy[1].data array([1., 2., 3.])
- connect(port: str | None = None, timeout: float | None = None, retries: int | None = None) None #
Try to connect to DataLab XML-RPC server.
- Parameters:
- Raises:
ConnectionRefusedError â Unable to connect to DataLab
ValueError â Invalid timeout (must be >= 0.0)
ValueError â Invalid number of retries (must be >= 1)
- add_signal(title: str, xdata: ndarray, ydata: ndarray, xunit: str | None = None, yunit: str | None = None, xlabel: str | None = None, ylabel: str | None = None) bool #
Add signal data to DataLab.
- Parameters:
title (str) â Signal title
xdata (numpy.ndarray) â X data
ydata (numpy.ndarray) â Y data
xunit (str | None) â X unit. Defaults to None.
yunit (str | None) â Y unit. Defaults to None.
xlabel (str | None) â X label. Defaults to None.
ylabel (str | None) â Y label. Defaults to None.
- Returns:
True if signal was added successfully, False otherwise
- Return type:
- Raises:
ValueError â Invalid xdata dtype
ValueError â Invalid ydata dtype
- add_image(title: str, data: ndarray, xunit: str | None = None, yunit: str | None = None, zunit: str | None = None, xlabel: str | None = None, ylabel: str | None = None, zlabel: str | None = None) bool #
Add image data to DataLab.
- Parameters:
title (str) â Image title
data (numpy.ndarray) â Image data
xunit (str | None) â X unit. Defaults to None.
yunit (str | None) â Y unit. Defaults to None.
zunit (str | None) â Z unit. Defaults to None.
xlabel (str | None) â X label. Defaults to None.
ylabel (str | None) â Y label. Defaults to None.
zlabel (str | None) â Z label. Defaults to None.
- Returns:
True if image was added successfully, False otherwise
- Return type:
- Raises:
ValueError â Invalid data dtype
- calc(name: str, param: DataSet | None = None) DataSet #
Call compute function
name
in current panelâs processor.- Parameters:
name (str) â Compute function name
param (guidata.dataset.DataSet | None) â Compute function parameter. Defaults to None.
- Returns:
Compute function result
- Return type:
- get_object(nb_id_title: int | str | None = None, panel: str | None = None) SignalObj | ImageObj #
Get object (signal/image) from index.
- Parameters:
nb_id_title â Object number, or object id, or object title. Defaults to None (current object).
panel â Panel name. Defaults to None (current panel).
- Returns:
Object
- Raises:
KeyError â if object not found
- get_object_shapes(nb_id_title: int | str | None = None, panel: str | None = None) list #
Get plot item shapes associated to object (signal/image).
- Parameters:
nb_id_title â Object number, or object id, or object title. Defaults to None (current object).
panel â Panel name. Defaults to None (current panel).
- Returns:
List of plot item shapes
- add_annotations_from_items(items: list, refresh_plot: bool = True, panel: str | None = None) None #
Add object annotations (annotation plot items).
- add_label_with_title(title: str | None = None, panel: str | None = None) None #
Add a label with object title on the associated plot
- context_no_refresh() Generator[None, None, None] #
Return a context manager to temporarily disable auto refresh.
- Returns:
Context manager
Example
>>> with proxy.context_no_refresh(): ... proxy.add_image("image1", data1) ... proxy.compute_fft() ... proxy.compute_wiener() ... proxy.compute_ifft() ... # Auto refresh is disabled during the above operations
- delete_metadata(refresh_plot: bool = True, keep_roi: bool = False) None #
Delete metadata of selected objects
- Parameters:
refresh_plot â Refresh plot. Defaults to True.
keep_roi â Keep ROI. Defaults to False.
- get_current_panel() str #
Return current panel name.
- Returns:
Panel name (valid values: âsignalâ, âimageâ, âmacroâ))
- Return type:
- get_group_titles_with_object_infos() tuple[list[str], list[list[str]], list[list[str]]] #
Return groups titles and lists of inner objects uuids and titles.
- Returns:
groups titles, lists of inner objects uuids and titles
- Return type:
Tuple
- get_object_titles(panel: str | None = None) list[str] #
Get object (signal/image) list for current panel. Objects are sorted by group number and object index in group.
- Parameters:
panel â panel name (valid values: âsignalâ, âimageâ, âmacroâ). If None, current data panel is used (i.e. signal or image panel).
- Returns:
List of object titles
- Raises:
ValueError â if panel not found
- get_object_uuids(panel: str | None = None) list[str] #
Get object (signal/image) uuid list for current panel. Objects are sorted by group number and object index in group.
- Parameters:
panel (str | None) â panel name (valid values: âsignalâ, âimageâ). If None, current panel is used.
- Returns:
list of object uuids
- Return type:
- Raises:
ValueError â if panel not found
- get_sel_object_uuids(include_groups: bool = False) list[str] #
Return selected objects uuids.
- Parameters:
include_groups â If True, also return objects from selected groups.
- Returns:
List of selected objects uuids.
- import_h5_file(filename: str, reset_all: bool | None = None) None #
Open DataLab HDF5 browser to Import HDF5 file.
- import_macro_from_file(filename: str) None #
Import macro from file
- Parameters:
filename â Filename.
- load_from_files(filenames: list[str]) None #
Open objects from files in current panel (signals/images).
- Parameters:
filenames â list of file names
- open_h5_files(h5files: list[str] | None = None, import_all: bool | None = None, reset_all: bool | None = None) None #
Open a DataLab HDF5 file or import from any other HDF5 file.
- run_macro(number_or_title: int | str | None = None) None #
Run macro.
- Parameters:
number_or_title â Macro number, or macro title. Defaults to None (current macro).
- Raises:
ValueError â if macro not found
- save_to_h5_file(filename: str) None #
Save to a DataLab HDF5 file.
- Parameters:
filename (str) â HDF5 file name
- select_groups(selection: list[int | str] | None = None, panel: str | None = None) None #
Select groups in current panel.
- Parameters:
selection â List of group numbers (1 to N), or list of group uuids, or None to select all groups. Defaults to None.
panel (str | None) â panel name (valid values: âsignalâ, âimageâ). If None, current panel is used. Defaults to None.
- select_objects(selection: list[int | str], panel: str | None = None) None #
Select objects in current panel.
- Parameters:
selection â List of object numbers (1 to N) or uuids to select
panel â panel name (valid values: âsignalâ, âimageâ). If None, current panel is used. Defaults to None.
- set_current_panel(panel: str) None #
Switch to panel.
- Parameters:
panel (str) â Panel name (valid values: âsignalâ, âimageâ, âmacroâ))
- stop_macro(number_or_title: int | str | None = None) None #
Stop macro.
- Parameters:
number_or_title â Macro number, or macro title. Defaults to None (current macro).
- Raises:
ValueError â if macro not found
Public API: additional methods#
The remote control class methods (either using the proxy or the remote client)
may be completed with additional methods which are dynamically added at
runtime. This mechanism allows to access the methods of the processors of DataLab
(see cdl.core.gui.processor
).
Signal processor#
When working with signals, the methods of cdl.core.gui.processor.signal.SignalProcessor
may be accessed.
- class cdl.core.gui.processor.signal.SignalProcessor(panel: SignalPanel | ImagePanel, plotwidget: PlotWidget)
Object handling signal processing: operations, processing, computing
- compute_sum() None
Compute sum
- compute_average() None
Compute average
- compute_product() None
Compute product
- compute_roi_extraction(param: ROIDataParam | None = None) None
Extract Region Of Interest (ROI) from data
- compute_swap_axes() None
Swap data axes
- compute_abs() None
Compute absolute value
- compute_re() None
Compute real part
- compute_im() None
Compute imaginary part
- compute_astype(param: DataTypeSParam | None = None) None
Convert data type
- compute_log10() None
Compute Log10
- compute_quadratic_difference(obj2: SignalObj | None = None) None
Compute quadratic difference between two signals
- compute_peak_detection(param: PeakDetectionParam | None = None) None
Detect peaks from data
- compute_normalize(param: NormalizeYParam | None = None) None
Normalize data
- compute_derivative() None
Compute derivative
- compute_integral() None
Compute integral
- compute_calibration(param: XYCalibrateParam | None = None) None
Compute data linear calibration
- compute_threshold(param: ThresholdParam | None = None) None
Compute threshold clipping
- compute_gaussian_filter(param: GaussianParam | None = None) None
Compute gaussian filter
- compute_moving_average(param: MovingAverageParam | None = None) None
Compute moving average
- compute_moving_median(param: MovingMedianParam | None = None) None
Compute moving median
- compute_wiener() None
Compute Wiener filter
- compute_interpolation(obj2: SignalObj | None = None, param: InterpolationParam | None = None)
Compute interpolation
- compute_resampling(param: ResamplingParam | None = None)
Compute resampling
- compute_detrending(param: DetrendingParam | None = None)
Compute detrending
- compute_fit(name, fitdlgfunc)
Compute fitting curve
- compute_polyfit(param: PolynomialFitParam | None = None) None
Compute polynomial fitting curve
- compute_multigaussianfit() None
Compute multi-Gaussian fitting curve
- compute_fwhm(param: FWHMParam | None = None) dict[str, ResultShape]
Compute FWHM
- compute_fw1e2() dict[str, ResultShape]
Compute FW at 1/e²
- compute_histogram(param: HistogramParam | None = None) dict[str, ResultShape]
Compute histogram
Image processor#
When working with images, the methods of cdl.core.gui.processor.image.ImageProcessor
may be accessed.
- class cdl.core.gui.processor.image.ImageProcessor(panel: SignalPanel | ImagePanel, plotwidget: PlotWidget)
Object handling image processing: operations, processing, computing
- compute_sum() None
Compute sum
- compute_average() None
Compute average
- compute_product() None
Compute product
- compute_logp1(param: LogP1Param | None = None) None
Compute base 10 logarithm
- compute_rotate(param: RotateParam | None = None) None
Rotate data arbitrarily
- compute_rotate90() None
Rotate data 90°
- compute_rotate270() None
Rotate data 270°
- compute_fliph() None
Flip data horizontally
- compute_flipv() None
Flip data vertically
- reset_positions() None
Reset image positions
- compute_resize(param: ResizeParam | None = None) None
Resize image
- compute_binning(param: BinningParam | None = None) None
Binning image
- compute_roi_extraction(param: ROIDataParam | None = None) None
Extract Region Of Interest (ROI) from data
- compute_profile(param: ProfileParam | None = None) None
Compute profile
- compute_average_profile(param: AverageProfileParam | None = None) None
Compute average profile
- compute_radial_profile(param: RadialProfileParam | None = None) None
Compute radial profile
- compute_histogram(param: HistogramParam | None = None) None
Compute histogram
- compute_swap_axes() None
Swap data axes
- compute_abs() None
Compute absolute value
- compute_re() None
Compute real part
- compute_im() None
Compute imaginary part
- compute_astype(param: DataTypeIParam | None = None) None
Convert data type
- compute_log10() None
Compute Log10
- compute_quadratic_difference(obj2: ImageObj | None = None) None
Compute quadratic difference between two images
- compute_flatfield(obj2: ImageObj | None = None, param: FlatFieldParam | None = None) None
Compute flat field correction
- compute_calibration(param: ZCalibrateParam | None = None) None
Compute data linear calibration
- compute_threshold(param: ThresholdParam | None = None) None
Compute threshold clipping
- compute_gaussian_filter(param: GaussianParam | None = None) None
Compute gaussian filter
- compute_moving_average(param: MovingAverageParam | None = None) None
Compute moving average
- compute_moving_median(param: MovingMedianParam | None = None) None
Compute moving median
- compute_wiener() None
Compute Wiener filter
- compute_butterworth(param: ButterworthParam | None = None) None
Compute Butterworth filter
- compute_adjust_gamma(param: AdjustGammaParam | None = None) None
Compute gamma correction
- compute_adjust_log(param: AdjustLogParam | None = None) None
Compute log correction
- compute_adjust_sigmoid(param: AdjustSigmoidParam | None = None) None
Compute sigmoid correction
- compute_rescale_intensity(param: RescaleIntensityParam | None = None) None
Rescale image intensity levels
- compute_equalize_hist(param: EqualizeHistParam | None = None) None
Histogram equalization
- compute_equalize_adapthist(param: EqualizeAdaptHistParam | None = None) None
Adaptive histogram equalization
- compute_denoise_tv(param: DenoiseTVParam | None = None) None
Compute Total Variation denoising
- compute_denoise_bilateral(param: DenoiseBilateralParam | None = None) None
Compute bilateral filter denoising
- compute_denoise_wavelet(param: DenoiseWaveletParam | None = None) None
Compute Wavelet denoising
- compute_denoise_tophat(param: MorphologyParam | None = None) None
Denoise using White Top-Hat
- compute_white_tophat(param: MorphologyParam | None = None) None
Compute White Top-Hat
- compute_black_tophat(param: MorphologyParam | None = None) None
Compute Black Top-Hat
- compute_erosion(param: MorphologyParam | None = None) None
Compute Erosion
- compute_dilation(param: MorphologyParam | None = None) None
Compute Dilation
- compute_opening(param: MorphologyParam | None = None) None
Compute morphological opening
- compute_closing(param: MorphologyParam | None = None) None
Compute morphological closing
- compute_all_morphology(param: MorphologyParam | None = None) None
Compute all morphology filters
- compute_canny(param: CannyParam | None = None) None
Compute Canny filter
- compute_roberts() None
Compute Roberts filter
- compute_prewitt() None
Compute Prewitt filter
- compute_prewitt_h() None
Compute Prewitt filter (horizontal)
- compute_prewitt_v() None
Compute Prewitt filter (vertical)
- compute_sobel() None
Compute Sobel filter
- compute_sobel_h() None
Compute Sobel filter (horizontal)
- compute_sobel_v() None
Compute Sobel filter (vertical)
- compute_scharr() None
Compute Scharr filter
- compute_scharr_h() None
Compute Scharr filter (horizontal)
- compute_scharr_v() None
Compute Scharr filter (vertical)
- compute_farid() None
Compute Farid filter
- compute_farid_h() None
Compute Farid filter (horizontal)
- compute_farid_v() None
Compute Farid filter (vertical)
- compute_laplace() None
Compute Laplace filter
- compute_all_edges() None
Compute all edges
- compute_centroid() dict[str, ResultShape]
Compute image centroid
- compute_enclosing_circle() dict[str, ResultShape]
Compute minimum enclosing circle
- compute_peak_detection(param: Peak2DDetectionParam | None = None) dict[str, ResultShape]
Compute 2D peak detection
- compute_contour_shape(param: ContourShapeParam | None = None) dict[str, ResultShape]
Compute contour shape fit
- compute_hough_circle_peaks(param: HoughCircleParam | None = None) dict[str, ResultShape]
Compute peak detection based on a circle Hough transform
- compute_blob_dog(param: BlobDOGParam | None = None) dict[str, ResultShape]
Compute blob detection using Difference of Gaussian method
- compute_blob_doh(param: BlobDOHParam | None = None) dict[str, ResultShape]
Compute blob detection using Determinant of Hessian method
- compute_blob_log(param: BlobLOGParam | None = None) dict[str, ResultShape]
Compute blob detection using Laplacian of Gaussian method
- compute_blob_opencv(param: BlobOpenCVParam | None = None) dict[str, ResultShape]
Compute blob detection using OpenCV