wiheto / netplotbrain

A package to create simple 3D network visualizations on a brain.
Apache License 2.0
66 stars 7 forks source link

Roadmap #59

Open wiheto opened 1 year ago

wiheto commented 1 year ago

This is a collection of the long term roadmap (will start to use projects if more people contribute to this)

Released in #60

Bug fixes

Enhancements

New features

Improved Documentation

wiheto commented 1 year ago

Plot from bids

@deve now has obtaining edges from BIDS derivatives with "average" and "average and subtract" operations and can be grouped by tasks, sessions or a column of data in participants.tsv.

Added onto to do list

hasibagen commented 2 months ago

Is there a way to directly increase the brain size or add related functionalities?

Currently, I'm using the following code:

figpick, ax = netplotbrain.plot(template='MNI152NLin2009cAsym',
                                fig=figpick,
                                view=['LAR'])

# Set figure size
figpick.set_size_inches(20, 8)

# Save as an SVG file
figpick.savefig('/home/jade/app/edu/brain_plot.svg', format='svg', dpi=500)

to increase the image size, but this method also significantly increases the whitespace between the brains.

Is there a more effective way to enlarge the brains without increasing the surrounding whitespace?

wiheto commented 2 months ago

The simple answer is: no. The longer answer is: yes but you have to do it manually and it could distort the figure so do it with care. The ax object is a list of three axis objects. and you can manually scale the xlim, ylim, zlim. ax[0].get_xlim() . Here is a quickly generated code of how you could do that

# Get current limits
current_xlim = ax[0].get_xlim()
current_ylim = ax[0].get_ylim()
current_zlim = ax[0].get_zlim()

# look at xlim to see its range
print(current_xlim)

# Calculate ranges
xlim_range = current_xlim[1] - current_xlim[0]
ylim_range = current_ylim[1] - current_ylim[0]
zlim_range = current_zlim[1] - current_zlim[0]

# Calculate the aspect ratios
xy_aspect_ratio = ylim_range / xlim_range
xz_aspect_ratio = zlim_range / xlim_range

# Change xlim to [-1, 1]
new_xlim = (-1, 1)
new_xlim_range = new_xlim[1] - new_xlim[0]

# Adjust ylim and zlim proportionally based on the aspect ratios
new_ylim_range = new_xlim_range * xy_aspect_ratio
new_ylim = (current_ylim[0], current_ylim[0] + new_ylim_range)

new_zlim_range = new_xlim_range * xz_aspect_ratio
new_zlim = (current_zlim[0], current_zlim[0] + new_zlim_range)

# Set the new limits
ax[0].set_xlim(new_xlim)
ax[0].set_ylim(new_ylim)
ax[0].set_zlim(new_zlim)
hasibagen commented 2 months ago

The simple answer is: no. The longer answer is: yes but you have to do it manually and it could distort the figure so do it with care. The ax object is a list of three axis objects. and you can manually scale the xlim, ylim, zlim. ax[0].get_xlim() . Here is a quickly generated code of how you could do that

# Get current limits
current_xlim = ax[0].get_xlim()
current_ylim = ax[0].get_ylim()
current_zlim = ax[0].get_zlim()

# look at xlim to see its range
print(current_xlim)

# Calculate ranges
xlim_range = current_xlim[1] - current_xlim[0]
ylim_range = current_ylim[1] - current_ylim[0]
zlim_range = current_zlim[1] - current_zlim[0]

# Calculate the aspect ratios
xy_aspect_ratio = ylim_range / xlim_range
xz_aspect_ratio = zlim_range / xlim_range

# Change xlim to [-1, 1]
new_xlim = (-1, 1)
new_xlim_range = new_xlim[1] - new_xlim[0]

# Adjust ylim and zlim proportionally based on the aspect ratios
new_ylim_range = new_xlim_range * xy_aspect_ratio
new_ylim = (current_ylim[0], current_ylim[0] + new_ylim_range)

new_zlim_range = new_xlim_range * xz_aspect_ratio
new_zlim = (current_zlim[0], current_zlim[0] + new_zlim_range)

# Set the new limits
ax[0].set_xlim(new_xlim)
ax[0].set_ylim(new_ylim)
ax[0].set_zlim(new_zlim)

I will give this a try, thanks for your work.