'FlatSym' object has no attribute 'array' - python

I'm still learning to use FatSym to analyze medical images; But I keep getting this error 'FlatSym' object has no attribute 'array' This is my code
pip install numpy
pip install pylinac
from pylinac import FlatSym
my_file = r"C:\Users\xxxx.dcm"
my_img = FlatSym(path=my_file)
my_img.analyze(flatness_method='varian', symmetry_method='varian', vert_position=0.5, horiz_position=0.5)
AttributeError Traceback (most recent call last)
<ipython-input-25-0bda45c5e24c> in <module>
----> 1 my_img.analyze(flatness_method='varian', symmetry_method='varian', vert_position=0.5, horiz_position=0.5)
C:\ProgramData\Anaconda3\lib\site-packages\pylinac\flatsym.py in analyze(self, flatness_method, symmetry_method, vert_position, horiz_position, vert_width, horiz_width)
C:\ProgramData\Anaconda3\lib\site-packages\pylinac\flatsym.py in _calc_symmetry(self, method, vert_position, horiz_position, vert_width, horiz_width)
C:\ProgramData\Anaconda3\lib\site-packages\pylinac\flatsym.py in _get_vert_profile(self, vert_position, vert_width)
AttributeError: 'FlatSym' object has no attribute 'array'
What i'm missing here please? Thanks!

FlatSym you have imported is an object try this
from pylinac import FlatSym
my_file = r"C:\Users\xxxx.dcm"
my_img = FlatSym(my_file)

Related

AttributeError: type object 'Split' has no attribute 'Train'

I'm following a simple tutorial using Google colab.
(train_data,validation_data),test_data=tfds.load(name='imdb_reviews',
split=((tfds.Split.Train.subsplit([6,4])),tfds.Split.Test),
as_supervised=True)
After writing this code I'm getting the error as shown below:
AttributeError Traceback (most recent call last)
<ipython-input-10-facc01319dcb> in <module>()
1 (train_data,validation_data),test_data=tfds.load(name='imdb_reviews',
----> 2 split=((tfds.Split.Train.subsplit([6,4])),tfds.Split.Test),
3 as_supervised=True)
AttributeError: type object 'Split' has no attribute 'Train'
.subsplit was part of the deprecated API, so cannot be used anymore.
Instead you should use the new subsplit API: https://www.tensorflow.org/datasets/splits
ds1, ds2 = tfds.load(..., split=[ 'train[:50%]', 'train[50%:]'])
According the issue 1998.

what is causing "AttributeError: 'numpy.ndarray' object has no attribute 'diff'"

I am new to numpy and I am NOT understanding the documentation as regards diff. the code below throws the error. I am baffled any help would be appreciated.
Traceback (most recent call last):
File "/home/dave/Desktop/mcmtest/testhv calc.py", line 11, in <module>
r = np.log(close_prices).diff()
AttributeError: 'numpy.ndarray' object has no attribute 'diff'
here is the test code.
import numpy as np
from numpy import sqrt,mean,log,diff
import pandas as pd
close_prices = [178.97,175.5,171.07,171.85,172.43,172.99,167.37,164.34,162.71,\
156.41,155.15,159.54,163.03,156.49,160.5,167.78,167.43,166.97,167.96,171.51,171.11]
print (close_prices)
r = np.log(close_prices).diff()
print(r)
Given that numpy.ndarray is the Python type of "numpy arrays", the error is just saying that arrays don't have a diff method. diff is a function defined in the numpy module.
Instead of np.log(close_prices).diff(), do
np.diff(np.log(close_prices))

AttributeError: 'FFmpegWriter' object has no attribute '_proc'

I have some problem which i cannot find answer to. After installing scikit-video and FFmpeg i got this error:
AttributeError: 'FFmpegWriter' object has no attribute '_proc'
can you help me to find solution to this.
from skvideo.io import FFmpegWriter
def main():
...
video_writer = FFmpegWriter('video.mp4')
...
if __name__ == '__main__':
main()
Already tried to install pyaudio, reinstall FFmpeg and skvideo and install different versions of packages. Does not help at all.
Edit: an example of the full traceback resulting from /skvideo/io/abstract.py is below.
Traceback (most recent call last):
File "run_modules.py", line 93, in <module>
Pipeline.create_videos(video_attr, args.output_path, args.padded)
File "/home/leuko/.local/lib/python3.6/site-packages/skvideo/io/abstract.py", line 474, in close
if self._proc is None: # pragma: no cover
AttributeError: 'FFmpegWriter' object has no attribute '_proc'
I just ran into this issue, and found that FFmpegWriter was actually masking another error. My code was roughly like this:
with FFmpegWriter('/tmp/tmp.webm') as writer:
for frame in frames:
<code to generate out>
writer.writeFrame(out)
The code block before writer.writeFrame was raising an error, but I didn't see that because I didn't look at the full stack trace. I couldn't figure out why FFmpegWriter was throwing this error, but it made sense once I realized I wasn't actually writing any frames but was then trying to close the writer.

'Check' object has no attribute 'image' while using sightengine api

I am using sightengine API to detect child sexual abuse in images. In order to do that I am trying to detect the nudity level in an image using sightengine API. The following example is provided in the documentation itself.
from sightengine.client import SightengineClient
client = SightengineClient('api_user', 'api_key')
output = client.check('nudity').image('https://d3m9459r9kwism.cloudfront.net/img/examples/example7.jpg')
Apart from copying the same code I am getting the following error.
Traceback (most recent call last):
File "driver.py", line 3, in <module>
output = client.check('nudity').image('https://d3m9459r9kwism.cloudfront.net/img/examples/example7.jpg')
AttributeError: 'Check' object has no attribute 'image'
I have used both Python 2 and Python 3 for the same code but both raise the same error.
Try This:
from sightengine.client import SightengineClient
client = SightengineClient('API user', 'API secret')
checkNudity = client.check('nudity')
output1 = checkNudity.set_url('https://d3m9459r9kwism.cloudfront.net/img/examples/example7.jpg')
print(output1)

sns.countplot - 'AttributeError: 'module' object has no attribute 'countplot''

I am trying to create a countplot with sns. I adapted the following code:
sns.countplot(x="deck", data=titanic, palette="Greens_d")
I use a data frame called dfvp where XP is a categorical variable which can take two string values (either defense or prosecution).
here is my adapted code:
sns.countplot(x="XP", data=dfvp, palette="Greens_d")
Here is the error message that I get:
sns.countplot(x="XP", data=dfvp, palette="Greens_d")
Traceback (most recent call last):
File "<ipython-input-220-20d65ae5d282>", line 1, in <module>
sns.countplot(x="XP", data=dfvp, palette="Greens_d")
AttributeError: 'module' object has no attribute 'countplot'
FYI: I use ANACONDA and Python 3.4. on a PC with Windows 8.
Could you tell me how to fix this/what I am doing wrong?
EDIT:
Here is a MCVE
import seaborn as sns
dfvp = read_csv('C:\\Users\\VP_Prod_study_2_data changed_3.csv')
sns.countplot(x="XP", data=dfvp, palette="Greens_d")

Categories